Click to See Complete Forum and Search --> : How to: Set a minimal size of a window ?
MeierD
May 25th, 1999, 09:40 AM
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
Catch WM_SIZE and adjust the size before sending it to base class' implmentation of size handler.
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
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
Oliver Kinne
May 26th, 1999, 02:11 AM
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?
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.