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

    How to: Set a minimal size of a window ?

    Hi,
    Could anyone explain how I can permanently set
    the minimal size of a MainFrame (main window of
    application) ?
    I would like to prevent window from resizing smaler at a minimal size limit ?

    Thanks for your help.

    Regards,

    Daniel



  2. #2
    Guest

    Re: How to: Set a minimal size of a window ?

    Catch WM_SIZE and adjust the size before sending it to base class' implmentation of size handler.


  3. #3
    Guest

    Re: How to: Set a minimal size of a window ?

    Control window size this way:

    void CYourFrame::OnGetMinMaxInfo( MINMAXINFO FAR* lpMMI )
    {
    CSize szIcon;
    CSize szSpace;
    CSize szThumb;
    CSize szBorder;

    szIcon.cx = ::GetSystemMetrics( SM_CXICON );
    szIcon.cy = ::GetSystemMetrics( SM_CYICON );
    szSpace.cx = ::GetSystemMetrics( SM_CXICONSPACING );
    szSpace.cy = ::GetSystemMetrics( SM_CYICONSPACING );
    szThumb.cx = ::GetSystemMetrics( SM_CXHTHUMB );
    szThumb.cy = ::GetSystemMetrics( SM_CYVTHUMB );
    szBorder.cy = ::GetSystemMetrics( SM_CYCAPTION );

    lpMMI->ptMinTrackSize.x = szIcon.cx + szThumb.cx + szSpace.cx + 20;
    lpMMI->ptMinTrackSize.y = szIcon.cy + szSpace.cy + szBorder.cy + 60;
    }

    the key is setting the values in lpMMI accordingly...
    hope this helps


  4. #4
    Guest

    Re: How to: Set a minimal size of a window ?

    You can't do this, unfortunately! Override OnGetMinMaxInfo() as explained in a previous note.

    General comment:
    You can't "fake" Windows into using different values for wParam and lParam by handling a message, changing the args and calling the base class handler.

    /ravi



  5. #5
    Join Date
    May 1999
    Location
    United Kingdom
    Posts
    136

    Re: How to: Set a minimal size of a window ?

    I tried this on my View class (derived from CFormView), but it wouldn't work. I set the values to all sorts of big and small sizes (i.e. 10x10 up to 400x400 and some in between), but I could still resize the window to any size. I tried this on NT.

    Any ideas?


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