How to hide MDI child form in Delphi?

How can I hide the MDIChild window in Delphi?

I use this code in the FormClose () event for my MDI children, but it does not work:

procedure TfrmInstrument.FormClose(Sender: TObject; var Action: TCloseAction); begin Action := caNone; ShowWindow(Handle, SW_HIDE); frmMainForm.MDIChildClosed(Handle); end; 

My child window is minimized, not hidden.

+4
source share
2 answers

TCustomForm has a protected procedure defined as:

 procedure TCustomForm.VisibleChanging; begin if (FormStyle = fsMDIChild) and Visible and (Parent = nil) then raise EInvalidOperation.Create(SMDIChildNotVisible); end; 

Override it in the MDI child windows as:

 procedure TMDIChildForm.VisibleChanging; begin // :-P end; 

Here is a simple example

After reading Jeroen's comment, I tried another solution that also works, but with a little flicker:

 procedure TMDIChildForm.VisibleChanging; begin if Visible then FormStyle := fsNormal else FormStyle := fsMDIChild; end; 

Perhaps this works on all versions of Windows.

PS: I did not find problems with the first solution for Windows 2k3SP2 x86 and Windows 7 Ultimate x86

+7
source

You cannot hide the MDI child window. This is a limitation of Win32.

0
source

All Articles