Click to See Complete Forum and Search --> : Prevent Window Move
udurai
June 10th, 1999, 10:06 AM
Hi:
Can anyone tell me how to prevent Window Move ?
I am trapping the ON_WM_MOVING() message and in my "void OnMoving(UINT fwSide, LPRECT pRect)" do NOT call the base class "CPropertySheet::OnMoving(fwSide, pRect);" the window still moves. How do I prevent window move?
Thank you.
blarivie
June 10th, 1999, 11:45 AM
Did you try OnGetMinMaxInfo()?
Gomez Addams
June 10th, 1999, 12:12 PM
My favorite method is to override OnNcHitTest.
You can fake windoze into thinking the mouse NEVER hits the title
area and therefore the window can't be moved. This applies to
resizing also. Check the docs for more details.
udurai
June 10th, 1999, 02:27 PM
Thank you for your suggestion. It works fine for my CDialog.
But, how can I do similar stuff for "CView".
What can I override to prevent move and resize of view ?
Gomez Addams
June 10th, 1999, 02:42 PM
Overriding OnNcHitTest will work for views also.
It is a bit better suited for main frames but will work
for child frames because there more issues to watch
out for with MDI like cascade and tile of multiple views.
I have used this with SDI apps successfully and I used
it on an MDI app where each view was derived from
CFormView and I locked out resizing and moving of
the child frames and left moving of the main frame
enabled.
udurai
June 10th, 1999, 03:17 PM
I tried it. My class is derived from CView and "OnNcHitTest(CPoint point)" is called only when the mouse is in the client area ( when OnNcHitTest() returns HTCLIENT ). When the mouse is anywhere else( title bar, min/max buttons ) this message handler is not called at all. What can I do to correct this?
chris law
June 11th, 1999, 01:23 AM
Did you do it in CChildFrame?????
(or in your view, that only fills the client area of the child frame)
chrislaw
udurai
June 11th, 1999, 03:59 PM
Hi, that was exactly where I was doing it and hence the problem. I moved the code to CChildFrame and it works perfect.
Thank you.
Gomez Addams
June 11th, 1999, 05:36 PM
I am glad to hear that you have it working.
I apologize if I misled you. Although my post
did mention child frames, I wasn't clear on
saying that the check needs to be in the frame
class, not the view class. Again, I apologize.
Dan Haddix
June 13th, 1999, 05:33 PM
This is a little off topic, but you said you use this method to prevent resizing of a window too why??? Simply removing the WS_THICKFRAME from your window class prevents resizing!!! For example you can remove the WS_THICKFRAME style from an appwizard generated project by adding
cs.style &= ~WS_THICKFRAME;
to the CMainFrame's PreCreateWindow function. If you want to constrain a window to a specific size you can override the OnGetMinMaxInfo handler and modify the MINMAXINFO structure.
Gomez Addams
June 14th, 1999, 01:27 PM
The only reason I do this is because I don't like the appearance of windows
that have WS_THICKFRAME turned off. This method allows you to set pretty
much whatever frame styles you want and have control of sizing and moving.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.