get notified when a Form is Minimized or Maximized?

Author: Thomas Stutz 

 

 

private

 

procedure WMSysCommand(var Msg: TWMSysCommand); message WM_SYSCOMMAND;

 

  {...}

 

implementation

 

{...}

 

procedure TForm1.WMSysCommand(var Msg: TWMSysCommand);

begin

  if (Msg.CmdType = SC_MINIMIZE) then

    ShowMessage('Minimize')

  else if (Msg.CmdType = SC_MAXIMIZE) then

    ShowMessage('Maximize');

  DefaultHandler(Msg);

end;