Solved

disable window movement

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Expand macro to ask for filename column 8 40
Replacement selected text 2 69
java ^ examples 8 75
building a service to accessed via telnet client, want colors ? 4 108
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. …
In this post we will learn different types of Android Layout and some basics of an Android App.
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.

751 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