Setting Minimum and Maximum Window Size on Visual C++
If you're using dialog based UI, it's quite simple. Just add this line in the MessageMap
BEGIN_MESSAGE_MAP(CDialogDlg, CDialog)
... ON_WM_GETMINMAXINFO()
END_MESSAGE_MAP()
and then add the function into your dialog class:
void CDialogDlg::OnGetMinMaxInfo( MINMAXINFO FAR* pMinMaxInfo )
{
// Preferred Maximum X & Y.
const int MAX_SIZE_X = 750;
const int MAX_SIZE_Y = 650;
// Preferred Minimum X & Y.
const int MIN_SIZE_X = 400;
const int MIN_SIZE_Y = 350;
// Set the maximum size. Used while maximizing.
pMinMaxInfo->ptMaxSize.x = MAX_SIZE_X;
pMinMaxInfo->ptMaxSize.y = MAX_SIZE_Y;
// Set the Minimum Track Size. Used while resizing.
pMinMaxInfo->ptMinTrackSize.x = MIN_SIZE_X;
pMinMaxInfo->ptMinTrackSize.y = MIN_SIZE_Y;
// Set the Maximum Track Size. Used while resizing.
pMinMaxInfo->ptMaxTrackSize.x = MAX_SIZE_X;
pMinMaxInfo->ptMaxTrackSize.y = MAX_SIZE_Y;
}
Don't forget to enable the Minimize and Maximize box in your dialog, then Voila.. your dialog box will changed.
Labels: dialog, mfc, programming, size
0 Comments:
Post a Comment
<< Home