Home > MFC, Windows API > Restricting window size

Restricting window size

Easy!

Handle WM_GETMINMAXINFO, LPARAM of this message points to a MINMAXINFO structure. Fill out necessary information into this structure like minimum and maximum tracking size, maximum position, maximum size.

If you’ve handled and filled out necessary information then return FALSE to so that the changes get’s applied.

If you are using MFC then add a message map entry for ON_WM_GETMINMAXINFO,

BEGIN_MESSAGE_MAP( CMyDlg, CDialog)
  ON_WM_GETMINMAXINFO()
END_MESSAGE_MAP()

// then provide a function whose signature is likewise...
// Declaration
void OnGetMinMaxInfo(MINMAXINFO* MinMaxInfo);

// Implementation will look something like this, I am here restricting minimum size...
void CWnd::OnGetMinMaxInfo(MINMAXINFO* MinMaxInfo)
{
  MinMaxInfo->ptMinTrackSize.x = GetSystemMetrics( SM_CXSCREEN )/4;
  MinMaxInfo->ptMinTrackSize.y = GetSystemMetrics( SM_CYSCREEN )/4;
}
Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: