CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 11 of 11
  1. #1
    Join Date
    Jun 1999
    Posts
    4

    Prevent Window Move

    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.


  2. #2
    Join Date
    Apr 1999
    Posts
    3

    Re: Prevent Window Move

    Did you try OnGetMinMaxInfo()?


  3. #3
    Join Date
    May 1999
    Location
    Oregon, USA
    Posts
    302

    Re: Prevent Window Move

    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.


  4. #4
    Join Date
    Jun 1999
    Posts
    4

    Re: Prevent Window Move

    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 ?


  5. #5
    Join Date
    May 1999
    Location
    Oregon, USA
    Posts
    302

    Re: Prevent Window Move

    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.



  6. #6
    Join Date
    Jun 1999
    Posts
    4

    Re: Prevent Window Move

    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?


  7. #7
    Join Date
    May 1999
    Posts
    69

    Re: Prevent Window Move

    Did you do it in CChildFrame?????
    (or in your view, that only fills the client area of the child frame)

    chrislaw

  8. #8
    Join Date
    Jun 1999
    Posts
    4

    Re: Prevent Window Move

    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.


  9. #9
    Join Date
    May 1999
    Location
    Oregon, USA
    Posts
    302

    Re: Prevent Window Move

    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.



  10. #10
    Join Date
    May 1999
    Posts
    82

    Re: Prevent Window Move

    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.


  11. #11
    Join Date
    May 1999
    Location
    Oregon, USA
    Posts
    302

    Re: Prevent Window Move

    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.



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured