Keeping the icon in the taskbar

Thamrin
Thamrin used Ask the Experts™
on
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
Comment
Watch Question

Do more with

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

Try this one:

type
 TForm1 = class(TForm)
   procedure FormCreate(Sender: TObject);
 private
 protected
   FMsgTaskbarCreated : dword;
   procedure WndProc(var Message: TMessage); override;
 public
 end;

var
 Form1: TForm1;

implementation

{$R *.dfm}

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

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

Regards, Geo

Author

Commented:
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