Solved

disable window movement

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
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 this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

762 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now