Author: Tomas Rutkauskas
How to intercept the maximize command
Answer:
If you want to restrict your window's maximum size (or minimum size, for that
matter), you may try to intercept WM_SYSCOMMAND and check for the value of wParam.
More elegant is to intercept WM_GETMINMAXINFO, as the following example shows:
1 type2 TMyForm = class(TForm)
3 procedure _WM_GETMINMAXINFO(var mmInfo: TWMGETMINMAXINFO); message4 wm_GetMinMaxInfo;
5 end;
6 7 //..8 9 procedure TMyForm._WM_GETMINMAXINFO(var mmInfo: TWMGETMINMAXINFO);
10 begin11 with mmInfo.minmaxinfo^ do12 begin13 // allow at most half of the screen, and position it in the middle14 ptmaxposition.x := Screen.Width div 4;
15 ptmaxposition.y := Screen.Height div 4;
16 17 ptmaxsize.x := Screen.Width div 2;
18 ptmaxsize.y := Screen.Height div 2;
19 end;
20 end;
21 22 end.