Mega Code Archive

 
Categories / Delphi / Forms
 

Preventing form from maximizing without disabling the maximize button

Title: Preventing form from maximizing without disabling the maximize button Question: Sometimes I wish to prevent my form from maximizing, but it is not suitable for me to disable the maximize button. How can I achieve this? Answer: Info: Occasionally I need disable the maximize button, but using the bordericons set sometimes causes my components to be redrawn incorrectly. Here's my solution. Whenever they are not allowed to resize (dictated by the condition), the computer will beep to warn the user. Definition: procedure WMSysCommand(var Msg: TWMSysCommand); message WM_SYSCOMMAND; Declaration: procedure TMainFrm.WMSysCommand; begin if (Msg.CmdType = SC_MAXIMIZE) and (optional condition here) then MessageBeep(0) else inherited; end; Tested with D5 using W2K/95/98 and NT4 Should work on other delphi versions.