How to minimize application with modal window

When you minimize modal window, this window is “hidden” behind (or below) application main form. Using this simple trick, we can minimize also the main application window together with modal “child” window.

.
.
.
private
procedure WMSyscommand(var Msg: TWmSysCommand); message WM_SYSCOMMAND;

.
.
.
procedure TForm1.WMSysCommand(var Msg: TWmSysCommand);
begin
  case (Msg.CmdType and $FFF0) of
    SC_MINIMIZE:  begin
                    Msg.Result := 0;
                    EnableWindow(Application.Handle, True);
                    Aplication.Minimize;
                  end;
    else inherited;
  end;
end;

Leave a Reply