Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

disable window movement

Posted on 1997-05-17
3
Medium Priority
?
370 Views
Last Modified: 2013-11-19
Hello I 'm using Visual C++ 1.52 and have a CFormView project. The way it works now is the user can drag the main window by it's title bar. I want to disable this feature for this window. For some odd reason I can't get the
following function to respond when I use the mouse left button over the title bar. If I could get the nHitTest to return HTCAPTION when over the title bar. I could trick it to think the mouse is over something else by returning HTNOWHERE.  Unfortunately, when I left click onto the title bar it won't go into the function. I tried tracing it with no luck! What am I doing wrong??? Note: I had the MFC app wizard make the following function with it's correct declaration and messages (it looks right).... it
should of worked ... I thought.  Steve sguit@aol.com

void CPmixView::OnNcLButtonDown(UINT nHitTest, CPoint point)
{
      // TODO: Add your message handler code here and/or call default

                   TRACE("%s\n","test");

       CFormView::OnNcLButtonDown(nHitTest, point);
}

0
Comment
Question by:sled
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 

Author Comment

by:sled
ID: 1301612
Adjusted points to 50
0
 
LVL 10

Accepted Solution

by:
RONSLOW earned 100 total points
ID: 1301613
You are responding in the VIEW instead of the FRAME - move your OnNcLButtonDown code to your main frame class instead.

Of course, you will also need to disable some system menu function (notably the Move function) - otherwise the user can still move the window around (without draggin by the title bar).

And what if the use tiles or cascades his desktop.  That will move your application window as wel;.

There are some any ways of doing a particular operation, it is often very hard to stop ALL the ways of doing it.

If I were you I would reconsider trying to stop people from doing things, but instead just make sure your program behaves correctly and takes appropriate actions when they do - odds are in a subsequent version of Windows there'll be yet ANOTHER way of moving a window etc that you don't handle and you'll need to change your code again.

0
 

Author Comment

by:sled
ID: 1301614
RONSLOW's  thanks..... I must not of been awake to realize I made the call from the wrong class!  Here is the needed code (one way) for a user to disable window movement. it fools the mainframe into thinking that you clicked on the client area not the caption bar!

UINT CMainFrame::OnNcHitTest(CPoint point)
{
   UINT nHitTest = CFrameWnd::OnNcHitTest(point);
   return (nHitTest == HTCAPTION) ? HTCLIENT : nHitTest;
}


0

Featured Post

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

671 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question