Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2008-07

Catching minimize on windows

5 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Søren Ager

Hi,

Lazarus v0.9.25 r15649M i386-win32-win32/win64 on windows XP.

I am working on a TrayIcon gadget and want it to minimize to the tray. Only problem is I can't seem to catch the Minimize event. I found a tutorial on the net based on Delphi and it used the following code:

procedure TMainForm.FormCreate(Sender: TObject);
begin
   Application.OnMinimize := @MinimizeMe;
end;
procedure TMainForm.MinimizeMe(Sender: TObject);
begin
   Visible := False;
end;

But MinimizeMe is never called.

Then I tried:

procedure TMainForm.FormWindowStateChange(Sender: TObject);
begin
   If WindowState = wsMinimized then
     Visible:=false;
end;

But that never gets called either :-(

Any hints are most welcome

Take care
S?ren

Reply by email

Luca Olivetti
to Søren Ager

En/na S?ren Ager ha escrit:

Show quoted text 20 lines
Hi, Lazarus v0.9.25 r15649M i386-win32-win32/win64 on windows XP. I am working on a TrayIcon gadget and want it to minimize to the tray. Only problem is I can't seem to catch the Minimize event. I found a tutorial on the net based on Delphi and it used the following code: procedure TMainForm.FormCreate(Sender: TObject); begin Application.OnMinimize := @MinimizeMe; end; procedure TMainForm.MinimizeMe(Sender: TObject); begin Visible := False; end; But MinimizeMe is never called.

I just tried dropping a TApplicationProperties object on the form (in the "Additional" tab) and assigning an event to OnMinimize and it seems to work here, with revision 15358.
I also tried the same as you (manually adding the event in FormCreate) and it works here.

Bye

Luca Olivetti Wetron Automatizaci?n S.A. http://www.wetron.es/ Tel. +34 93 5883004 Fax +34 93 5883007

Reply by email

Søren Ager
to Luca Olivetti
Luca Olivetti wrote
I just tried dropping a TApplicationProperties object on the form (in the "Additional" tab)

I hadn't found that one thanks for the tip.

and assigning an event to OnMinimize and it seems to work here, with revision 15358.

Turns out to be a programmer error..... Thanks for the help.

Now I just need to figure out why Hide or Visible:=false does not remove
the window from the task bar.

Take care,
S?ren

Reply by email

Søren Ager
to Luca Olivetti
Luca Olivetti wrote 6 lines
En/na S?ren Ager ha escrit: > Now I just need to figure out why Hide or Visible:=false does not remove > the window from the task bar. Maybe you should use the ShowInTaskbar form property

I read somewhere that ShowInTaskbar is only used during startup of the application after that it is read only. Anyway it did not work either way.

After a lot of Googleing I finally found the answer:

procedure TMainForm.MinimizeMe(Sender: TObject);
var
   OwnerWnd : HWnd;
begin
   OwnerWnd:=GetWindow(Handle,GW_OWNER);
   ShowWindow(OwnerWnd,SW_HIDE);
end;

Take care,
S?ren

Reply by email