3
votes

Other than my main form, I need my forms to notify my main form and hide when I minimize them (instead of beeing minimized to the desktop window).

How can this be done?

My forms are created like this: How to make my Forms always to be on top my main form?

1

1 Answers

5
votes

Handle the WM_SYSCOMMAND message to detect the minimize:

type
  TMyForm = class(TForm)
  ....
  protected 
    procedure WMSysCommand(var Message: TWMSysCommand); message WM_SYSCOMMAND;
  ....
  end;
....
procedure TMyForm.WMSysCommand(var Message: TWMSysCommand);
begin
  if Message.CmdType and $FFF0 = SC_MINIMIZE then
    Hide
  else
    inherited;
end;

You can also notify the main form at this point by whatever mechanism you choose.