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!

Hiding MDI parent forms that contain child forms 1

Status
Not open for further replies.

OmniCog

Programmer
Jan 23, 2004
27
CA
I am new to Delphi with experience in interpreted languages like Perl + PHP and have little-to-none experience in compiled langauges.

I am trying to send an MDI parent form with several child forms to tray.

Here is the code I have so far:
...
private
TrayIconData: TNotifyIconData;
...

procedure TMainForm.SendtoTray();
begin
with TrayIconData do
begin
cbSize := SizeOf(TrayIconData);
Wnd := Handle;
uID := 0;
uFlags := NIF_MESSAGE + NIF_ICON + NIF_TIP;
uCallbackMessage := WM_ICONTRAY;
hIcon := Application.Icon.Handle;
StrPCopy(szTip, Application.Title);
end;

Shell_NotifyIcon(NIM_ADD, @TrayIconData);

MainForm.Hide;
end;

but if MainForm has a child form, the application seems to just minimize to taskbar and create an icon in the tray.

TIA
 
Try doing this:
Code:
  Application.CreateForm(...);
  [b]Application.ShowMainForm := False; // <- ADD THIS[/b]
  Application.Run;
in the DPR file.

Never tried with a MDI app, they are tricky and I dont use them too much.

buho (A).

 
I must have tried that already because I have that commented out.

I have to &quot;free&quot; my forms before the function works properly but what is the best method to &quot;un-free&quot; or re-create my forms?
 
The way to create a form (or any other object) is:

frm := TMyForm.Create(...);

where frm is a variable assingment-compatible with TMyForm and TMyForm the type of the form you want to create.

Why you need to free your form? Are your freeing the app main form?

buho (A).

 
Addendum:

Try using ShowWindow(Application.Handle, SW_HIDE) after the Hide statement (and uncomment the ShowMainForm := False).

buho (A).


 
Works perfectly thanks allot! I apologize for the late reply but I've been busy for the past week.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top