Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

disable window movement

Posted on 1997-05-17
3
Medium Priority
?
371 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
  • 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Ready to get certified? Check out some courses that help you prepare for third-party exams.
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
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.
Suggested Courses

927 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