Limiting the Size of a Window

Date: 10 July 1997
Author: Christopher Kohlhoff

Frame windows (such as an application's main window or an MDI child) can be resized by the user if they have a thick frame. To limit the size which this window can be resized, you need to handle the WM_GETMINMAXINFO message.

To handle the WM_GETMINMAXINFO message you add the following entry to your window's response table:

DEFINE_RESPONSE_TABLE1(TMyWindow, TFrameWindow)
  // ...
  EV_WM_GETMINMAXINFO,
  // ...
END_RESPONSE_TABLE;

You then need to add a function called EvGetMinMaxInfo to your window class:

void TMyWindow::EvGetMinMaxInfo(MINMAXINFO& info)
{
  // set the minimum size
  info.ptMinTrackSize.x = 150;
  info.ptMinTrackSize.y = 150;

  // set the maximum size
  info.ptMaxTrackSize.x = 400;
  info.ptMaxTrackSize.y = 300;
}