TTrayIcon in start up! lazarus / 13-General ---------------------------------------------------------------------- Bandbaz · 2009-11-10 17:04 I have a strange problem with TTrayIcon. It works well in my project. But when I put my application on 'startup applications' and restart, Icon is not visible. ---------------------- The project starts with only a TrayIcon. (I have 'Application.ShowMainForm:=False' in the main unit) A popup menu should call some forms. And there is a timer that call TrayIcon/Balloon sometimes. When I run my compiled project, everything is ok. But when I add it to Startup applications, after restart; I can see my application in processes. (->It is runing) I can see the TrayIcon/Balloon in it's time. (-> It's working) But I can't see the icon in the tray notify area. ---------------------- I use Ubuntu 9.04 and Lazarus 0.9.28.2-0 Beta I don't know even is this a problem with my source, Lazarus or Linux? ---------------------- This is a part of source code: Application unit:   ...     Application.Initialize;     Application.CreateForm(TFMain, FMain);     Application.ShowMainForm:=False;     Application.Run;   ... UMain (TFMain):   procedure TFMain.FormCreate(Sender: TObject);   begin   ...     TrayIcon.Icon:=INormal.Picture.Icon;     TrayIcon.Show; {or TrayIcon.Visible:=True}   ...   end; ---------------------------------------------------------------------- bonmario · 2009-11-10 17:14 I had the same problem on Ubuntu, the same project under Windows XP works fine. I have "solved" in this way: - i put a timer on the project - after 1 minute (with the timer), i use this code: Code: [Select]        {$IFDEF LINUX}           MyTrayIcon.Hide;           MyTrayIcon.Visible:=False;           MyTrayIcon.Show;           MyTrayIcon.Visible:=True;           Timer1.Enabled:=False;         {$ENDIF} Hi, Mario ---------------------------------------------------------------------- Bandbaz · 2009-11-10 18:18 So.. You think this is a problem with Ubuntu? But other applications doesn't wait some seconds to show their tray icon. Thank you any way. This is useful for me. But I hope to find the reason!  If I want to publish this application it's not very beautiful... ---------------------------------------------------------------------- bonmario · 2009-11-10 19:11 I suppose that the problem is that the program is loaded before of the "startx". With a delay of one minute, on my PC, the icon is showed before that the desktop is totally ready. ---------------------------------------------------------------------- Bandbaz · 2009-11-11 17:20 I wrote this code: Code: [Select]type   TMainForm: class(TForm)     ATrayIcon: TTrayIcon; {$IFDEF LINUX}     ATimer: TTimer; // It's not on the form designer.     procedure ATimerTimer(Sender: TObject); {$ENDIF}     ... procedure TMainForm.FormCreate(Sender: TObject); begin   ATrayIcon.Show; {$IFDEF LINUX}   if not ATrayIcon.Visible then begin     ATimer:=TTimer.Create(Self);     ATimer.Interval:=500; //or maybe less!     ATimer.OnTimer:=@ATimerTimer;     ATimer.Enabled:=True;   end; {$ENDIF} end; {$IFDEF LINUX} procedure TMainForm.ATimerTimer(Sender: TObject); begin   if ATrayIcon.Show then begin     ATimer.Enabled:=False; // Why I wrote this line?!     ATimer.Free;   end; end; {$ENDIF} If there is no other way, I think it's not bad idea to add this code (or something like this) to TrayIcon component. But what will happen if icon can't be visible because of any other reason? The application will tray to show the icon every 500 milliseconds forever!! And in your solution (showing the icon again after 1 minute), I'm not sure if it will work on every system or not. And I don't like to make it more than 1 minute. Because then I have to wait more after startup ... This is good for self using!! not for publishing. It's a bit strange if Ubuntu loads startup programs before itself (or at the same time)! Isn't it? Anyway .. I don't like this solution... ---------------------------------------------------------------------- felipemdc · 2009-11-11 17:49 I think you should check if the notification area is present instead of doing the timer thing. I will investigate about adding a method to check if the notification area is active. You could also check what works for Ubuntu, because I usually use Mandriva, so that could be different. ---------------------------------------------------------------------- Bandbaz · 2009-11-12 14:20 Thank you .. This is more logical way  But I have no idea about how to check if notification area is ready or not! I wish there is something like an event for it. or at least its possible to make that! Let me know if you found anything