23 May 2011

Hide MDI Child Form

Use the ShowWindow function instead:

To hide:

procedure T_mdi_child_form.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  inherited;
  //this resolves problem with maximized MDI active form close

  if Self.WindowState = wsMaximized then Self.WindowState := wsNormal ;

  Action := caNone;
  ShowWindow(self.WindowHandle, SW_HIDE);

end;


To show:

procedure T_mdi_child_form._action_show_Execute(Sender: TObject);
begin
  inherited;
  if _
mdi_child_form = Nil then
     Application.CreateForm(T_
mdi_child_form, _mdi_child_form);

  ShowWindow(_
mdi_child_form.Handle, SW_SHOW);
  _
mdi_child_form.BringToFront ;
end;

No comments: