CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 1 of 1
  1. #1
    Join Date
    Feb 2003
    Iasi - Romania

    MFC General: How to prevent a resizable window to be smaller than...?

    Q: How to prevent a resizable window to be smaller than...?

    A: Handle 'WM_GETMINMAXINFO' message:

    void CWndDerived::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)
      // set the minimum tracking width
      // and the minimum tracking height of the window
      lpMMI->ptMinTrackSize.x = 200;
      lpMMI->ptMinTrackSize.y = 150;

    Q: My resizable window is a dialog and I do not see 'WM_GETMINMAXINFO' in the messages list of ClassWizard. What can I do?

    A: Because 'WM_GETMINMAXINFO' is by default filtered by class wizard for a 'CDialog' derived class, you can add the 'ON_WM_GETMINMAXINFO()' macro and the corresponding handler function by hand, or:

    • in MFC ClassWizard select 'Class Info' tab and choose 'Window' from 'Message filter' combo.
    • go back to 'Message Maps', select your CDialog-derived class in 'Object IDs' list and then 'WM_GETMINMAXINFO' from the messages list.

    Q: My application is SDI/MDI. The required minimum size is given by the view. I handled 'WM_GETMINMAXINFO' in my CView-derived class but does not work. What I'm doing wrong?

    A: A view is not responsible for sizing. Handle 'WM_GETMINMAXINFO' in the corresponing frame window:

    void CChildFrame::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI) 
      // the minimum client rectangle (in that is lying the view window)
      CRect rc(0, 0, 200, 150);
      // compute the required size of the frame window rectangle
      // based on the desired client-rectangle size
      lpMMI->ptMinTrackSize.x = rc.Width();
      lpMMI->ptMinTrackSize.y = rc.Height();

    Q: My application is SDI/MDI. I don't want to be resizable at all.

    A: Set also the maximum track size:

    void CChildFrame::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI) 
      lpMMI->ptMinTrackSize.x = lpMMI->ptMaxTrackSize.x = 200;
      lpMMI->ptMinTrackSize.y = lpMMI->ptMaxTrackSize.y = 150;
    An alternative solution is to simply remove 'WS_THICKFRAME' style in 'PreCreateWindow()':

    BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs)
        return FALSE;
      cs.style &= ~WS_THICKFRAME;
      return TRUE;

    Last edited by Andreas Masur; July 24th, 2005 at 03:47 PM.

Posting Permissions

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

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)