Solved

disable window movement

Posted on 1997-05-17
3
367 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 50 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

740 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