Board index » delphi » Minimize the Application not just the form?

Minimize the Application not just the form?

Can anybody tell me how to Minimize the Application.(I'm using Delphi2.0.)

I've tried issuing  "Application.Minimize;"  which does minimize the
application however when
"restoring" the application the "MAIN" form is displayed instead of the
current one.

The other problem is that the second time "Application.Minimize;"  is
issued NOTHING happens.

What am I doning wrong?
Any help will be appreciated.

John
t...@dbn.lia.net

 

Re:Minimize the Application not just the form?


I had a similar problem with dialog forms in my Delphi 3 project. The way I
got around this was to do the following:

1. Create a public variable 'CurrentForm' of type 'THandle' in your main
form. In the FormCreate code of your main form add:
  Application.OnRestore := AppRestore;

2. Define the AppRestore function as follows:

procedure TfrmMain.AppRestore( Sender : TObject );
begin
  if CurrentForm <> 0 then
  begin
    ShowWindow( CurrentForm, SW_NORMAL );
    SetForegroundWindow( CurrentForm );
    CurrentForm := 0;
  end;
end;

3. In each form that you wish to minimize add the following code to the
'Resize' event:

procedure TfrmMain.FormResize(Sender: TObject);
begin
  if WindowState = wsMinimized then
  begin
    frmMain.CurrentForm := Handle;
    Application.Minimize;
  end;
end;

If there are any more elegant solutions to this problem I'd love to know.

Cheers
domin...@iafrica.com

Quote
John King wrote in message <01bd4057$52bea480$3dfd31ce@client>...
>Can anybody tell me how to Minimize the Application.(I'm using Delphi2.0.)

>I've tried issuing  "Application.Minimize;"  which does minimize the
>application however when
>"restoring" the application the "MAIN" form is displayed instead of the
>current one.

>The other problem is that the second time "Application.Minimize;"  is
>issued NOTHING happens.

>What am I doning wrong?
>Any help will be appreciated.

>John
>t...@dbn.lia.net

Other Threads