Capture Maximize/Minimize/Close button clicks

...
type
TForm1 = class(Form)
...
public
procedure WMSysCommand(var Msg: TWMSysCommand); message WM_SYSCOMMAND;
...
procedure TForm1.WMSysCommand(var Msg: TWMSysCommand);
begin
if Msg.CmdType = SC_MINIMIZE) or (Msg.CmdType = SC_MAXIMIZE) or (Msg.CmdType =
SC_CLOSE) then
...
else
DefaultHandler(Msg);
end;