Link to home
Start Free TrialLog in
Avatar of Bohne
Bohne

asked on

Form does not hide in Delphi 7

Hi,

I have an application that minimizes to the system tray. That's why I have a procedure AppMinimize which hides the application-form. The tray-icon is already present, so I don't have to initialize it.

When I click the icon, CMClickIcon is executed, which makes the window visible again!

And where is the problem now? All this works very well with Delphi 3. But with Delphi 7 I encounter a very strange problem: The application starts minimized, I click the icon, the application restores. I minimze the window, it disapears and only the icon is visible. I click the icon again, the application restores.

But now: I minimize the application, it minimizes but remains visible in the taskbar!!!
So the minimize works exactly one time! The second time it stays visible in the taskbar!!! Why this?!? Why does it only work the first time?!? And why does it work in Delphi 3 but not in Delphi 7?!?


Thank you very much for your help!



Here is the code i use:

procedure TForm1.AppMinimize(Sender:TObject);
begin
    Visible := FALSE;
    Application.ShowMainForm := Visible;
end;

procedure TForm1.CMClickIcon(var msg: TMessage);
begin
    Application.Restore;
    Visible := TRUE;
    Application.ShowMainForm := Visible;
    SetForegroundWindow(Application.Handle);
end;
Avatar of Knighty
Knighty

you could try

to show form:
  SendMessage(Self.Handle, WM_SYSCOMMAND, SC_RESTORE, 0);
  ShowWindow(Self.Handle, SW_SHOW);
  SetForegroundWindow(Self.Handle);

to hide:
  ShowWindow(Self.Handle, SW_HIDE);
Avatar of Bohne

ASKER

... I'm sorry, but this doesn't work at all! The form doesn't even hide once! It just minimizes. And afterwards it does not recover correctly! :-(

Any other ideas?
ASKER CERTIFIED SOLUTION
Avatar of grolschisgood
grolschisgood

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial