Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hide and Show Mdi Child Form

Status
Not open for further replies.

Spent

Programmer
Mar 20, 2003
100
BG
Can anyone tell me how to Hide and then to show again a Child MDIForm without loosing the content in the form.I tried .Hide but in run-time the exe tell me that I Cannot hide Mdi child.When I use .Close after that I can not open it again.
I am sure that there is a way can anyone show me this way :)
Thank you

Spent
mail:teknet@mail.orbitel.bg
 
Hi Spent,

you can do this, although you need 2 small tricks :

Code:
procedure TMDIChild.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  Action:=caNone;
end;

Normally this should close the form.
However, as stated, the default behavior for MDI child form OnClose event is to become minimized. Now, if you want to hide the form when it gets minimized you can use the next trick:

Code:
procedure TMDIChild.WMSize(var M:TWMSIZE); 
begin 
 if M.SizeType=Size_Minimized then 
  ShowWindow(Handle,Sw_Hide); 
end;


Don't forget to add the procedure header to the private part of the form type declaration:
Code:
 private 
  procedure WMSize(var M : TWMSIZE); Message WM_Size;

Cheers,
daddy




--------------------------------------
What You See Is What You Get
 
whosrdaddy The procedue wmsize do not works, maybe because I am using Delphi 5.The Error is that TWmsize is not recognized.
Can you tell me a solution for an older version of Delphi like mine which is Borland Delphi 5 ?

Spent
mail:teknet@mail.orbitel.bg
 
do you have included the 'messages' unit in your uses clause. if still not recognized, this is the definition of the twm_size structure.


Code:
  TWMSize = packed record
    Msg: Cardinal;
    SizeType: Longint; { SIZE_MAXIMIZED, SIZE_MINIMIZED, SIZE_RESTORED,
                         SIZE_MAXHIDE, SIZE_MAXSHOW }
    Width: Word;
    Height: Word;
    Result: Longint;
  end;

cheers

--------------------------------------
What You See Is What You Get
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top