[Lazarus] Loading icon from Application.Icon

Guionardo Furlan guionardo at gmail.com
Sun Feb 1 21:54:15 CET 2009


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.

Now, I could fix it using Lazarusresources.

2009/2/1 Felipe Monteiro de Carvalho <felipemonteiro.carvalho at gmail.com>:
> Can you post a very simple, but complete, example which fails?
>
> The code you showed on the first e-mail was too short to check if your
> code is wrong or if it's a bug in TIcon.
>
> --
> Felipe Monteiro de Carvalho
> _______________________________________________
> 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