Vlad
Vlad

Reputation: 1433

How to Hide my Forms when they are minimized?

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?

Upvotes: 5

Views: 742

Answers (1)

David Heffernan
David Heffernan

Reputation: 612794

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.

Upvotes: 7

Related Questions