private
procedure WMSysCommand(var Msg: TWMSysCommand); message WM_SYSCOMMAND;
...
procedure TForm.WMSysCommand(var Msg: TWMSysCommand);
begin
if (Msg.CmdType = SC_MAXIMIZE) then
...
else
if (Msg.CmdType = SC_MINIMIZE) then
...
else
if (Msg.CmdType = SC_RESTORE) then
...
else DefaultHandler(Msg);
end;