Examples Delphi

Title: React on the minimize button
Question: Does anybody know how to capture the minimize button press and act on
it before it actually minimizes the form?
Answer:
You should intercept WM_SYSCOMMAND messages like this:
type
TForm1 = class(TForm)
public
procedure WMSysCommand(var Msg: TWMSysCommand); message WM_SYSCOMMAND;
end;
procedure TForm1.WMSysCommand;
begin
if (Msg.CmdType = SC_MINIMIZE) or (Msg.CmdType = SC_MAXIMIZE) then
begin
// your code...
end;
DefaultHandler(Msg);
end;