[Lazarus] Loading icon from Application.Icon
Guionardo Furlan
guionardo at gmail.com
Mon Feb 2 18:50:33 CET 2009
Don't worked. The icon is loaded by the application.
begin
Application.Title := uTipos.ProgTitulo;
Application.Initialize;
Tray.Cria;
Application.Run;
end.
2009/2/1 Vincent Snijders <vincent.snijders at gmail.com>:
> Guionardo Furlan schreef:
>> The application don't have a main form.
>> Look:
>>
>> program nodort;
>>
>> {$mode objfpc}{$H+}
>>
>> uses
>> {$IFDEF UNIX} {$IFDEF UseCThreads}
>> cthreads,
>> {$ENDIF} {$ENDIF}
>> Interfaces, // this includes the LCL widgetset
>> Forms
>> { you can add units after this }, uEvento, uTrayIcon, uResources, uConfigura,
>> foConfig, uTipos;
>>
>> {$IFDEF WINDOWS}
>> {$R nodort.rc}
>> {$ENDIF}
>> begin
>> Application.Title := uTipos.ProgTitulo;
>> Application.Initialize;
>> Application.Run;
>> end.
>>
>> The uTrayIcon unit have a class TTray:
>>
>> TTray = class (TComponent)
>> FMenu: TPopupMenu;
>> FTrayIcon: TTrayIcon;
>> FTimer: TTimer;
>> procedure ClickMenu (Sender: TObject);
>> procedure TimerEvent(Sender: TObject);
>> private
>> FUltimaParada,
>> FProximoAlarme: TDateTime;
>> procedure CriaMenu;
>> procedure CriaTray;
>> procedure CriaTimer;
>> procedure Configura;
>> procedure AtualizaDica;
>> procedure PedePraParar;
>> public
>> procedure Cria;
>> property Menu: TPopupMenu read FMenu;
>> property TrayIcon: TTrayIcon read FTrayIcon;
>> end;
>>
>> In this unit, a global var Tray is defined and instantiated on the
>> initialization clause.
>>
>> initialization
>> Tray:=TTray.Create(Application);
>> Tray.Cria; // Here comes the second-fase creation task, where have:
>>
>> FTrayIcon:=TTrayIcon.Create(self);
>> FTrayIcon.Icon.Assign(Application.Icon);
>> FTrayIcon.PopUpMenu := FMenu;
>> FTrayIcon.Visible := True;
>> FTrayIcon.BalloonFlags:=bfInfo;
>>
>> The trayicon is enabled and can be found in the traybar. The popupmenu works.
>> But the icon image is empty. This is the problem.
>
> The Application.Icon might not be initialized until you run
> Application.Initialize. So you assign an empty icon to your trayicon.
>
> Vincent
> _______________________________________________
> Lazarus mailing list
> Lazarus at lazarus.freepascal.org
> http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
>
--
Timeo hominem unius libri
Cogito ergo sum - Carpe diem
[]s
Guionardo Furlan
http://guionardo.blogspot.com
More information about the Lazarus
mailing list