Keeping the icon in the taskbar

Thamrin used Ask the Experts™
I have written a small program that resides in the taskbar. Everything is perfect until the "explorer" suddenly closes itself, and when it comes up again the icons are gone (including my small program's icon).

Is there anyway to encounter this problem.
Any message sent by explorer when it has to close?

Thanks, Regards
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Try this one:

 TForm1 = class(TForm)
   procedure FormCreate(Sender: TObject);
   FMsgTaskbarCreated : dword;
   procedure WndProc(var Message: TMessage); override;

 Form1: TForm1;


{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
 FMsgTaskbarCreated := RegisterWindowMessage('TaskbarCreated');

procedure TForm1.WndProc(var Message: TMessage);
 if Message.Msg = FMsgTaskbarCreated then begin
   // add your icon to the task bar

Regards, Geo


Thank you very much geobul ^_^
It works...
Anyway can you explain how your code works?
That message is registered system-wide and is sent to all windows (broadcasted) every time when the taskbar is created (for the first time or when it's recreated after a crash). WndProc of your form receives the message when that event happens and creates its tray icon again.

By the way, why 'B' grade if you think that the code I gave you solved your problem? When you said that this question is for 50 points and when you accepted an answer your account would be decreased by 50 points no matter of the grade you would give. The grade defines how many points the expert will receive in his/her account.

Regards, Geo

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial