| View previous topic :: View next topic |
| Author |
Message |
Julien Moorrees Guest
|
Posted: Sun Jan 25, 2004 11:25 am Post subject: How to refresh the systemtray TrayIcon after explorer crash |
|
|
I am using the TrayIcon component from the example tab in c++ builde 6.
Everytime Explorer chrashes the systemtray icon is not refreshed.
I tried to create a Timer wich does the following:
void __fastcall Tsk_userlist::tmrCheckSystrayIconTimer(TObject *Sender)
{
if (tray->IconIndex ==0) {
tray->IconIndex=1;
tray->Update();
return;
} else {}
if (tray->IconIndex ==1) {
tray->IconIndex=0;
tray->Update();
return;
} else {}
}
But this doesn't seem to put the icon back. Does one of you know how to
do this correctly?
|
|
| Back to top |
|
 |
vERUs Guest
|
Posted: Sun Jan 25, 2004 1:51 pm Post subject: Re: How to refresh the systemtray TrayIcon after explorer cr |
|
|
| Quote: | But this doesn't seem to put the icon back. Does one of you know how to
do this correctly?
|
Take a look in the nativeapi newsgroup and search for "TrayIcon problem",
you'll find the answer to your problem there...
// vERUs
|
|
| Back to top |
|
 |
Eugene Mayevski [SecureBl Guest
|
Posted: Sun Jan 25, 2004 6:46 pm Post subject: Re: How to refresh the systemtray TrayIcon after explorer cr |
|
|
Julien Moorrees wrote:
| Quote: | I am using the TrayIcon component from the example tab in c++ builde 6.
Everytime Explorer chrashes the systemtray icon is not refreshed.
|
register window message as follows and handle this message in your
application. In message handler re-create the icon.
WM_TaskbarRestart := RegisterWindowMessage(PChar('TaskbarCreated'));
--
Eugene Mayevski
EldoS Corp., CTO
Security and networking solutions
http://www.eldos.com
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Sun Jan 25, 2004 10:42 pm Post subject: Re: How to refresh the systemtray TrayIcon after explorer cr |
|
|
"Julien Moorrees" <nws (AT) nims (DOT) nl> wrote
| Quote: | I tried to create a Timer wich does the following:
|
That in unnecessary. Whenever explorer is restarted, it broadcasts a
message to every top-level window when the taskbar has been created. You
can intercept that message and re-add your icon at that time. For example:
class TForm1 : public TForm
{
private:
UINT uTaskbarCreatedMsg;
protected:
void __fastcall WndProc(TMessage &Message);
public:
__fastcall TForm1(TComponent *Owner);
};
__fastcall TForm1::TForm1(TComponent *Owner)
: TForm(Owner)
{
uTaskbarCreatedMsg = RegisterWindowMessage("TaskbarCreated");
}
void __fastcall TForm1::WndProc(TMessage &Message)
{
if( (Message.Msg == uTaskbarCreatedMsg) && (uTaskbarCreatedMsg !=
0) )
{
// add your tray icon here...
Message.Result = TRUE;
}
else
TForm::WndProc(Message);
}
Gambit
|
|
| Back to top |
|
 |
Julien Moorrees Guest
|
Posted: Wed Mar 03, 2004 3:36 pm Post subject: Re: How to refresh the systemtray TrayIcon after explorer cr |
|
|
Remy Lebeau (TeamB) wrote:
| Quote: |
class TForm1 : public TForm
{
private:
UINT uTaskbarCreatedMsg;
protected:
void __fastcall WndProc(TMessage &Message);
public:
__fastcall TForm1(TComponent *Owner);
};
__fastcall TForm1::TForm1(TComponent *Owner)
: TForm(Owner)
{
uTaskbarCreatedMsg = RegisterWindowMessage("TaskbarCreated");
}
void __fastcall TForm1::WndProc(TMessage &Message)
{
if( (Message.Msg == uTaskbarCreatedMsg) && (uTaskbarCreatedMsg !=
0) )
{
// add your tray icon here...
Message.Result = TRUE;
}
else
TForm::WndProc(Message);
}
Gambit
|
Great solution! This works. In any case some-one is using the default
tray-icon object, use the following code:
// add your tray icon here...
try {
tray->Hide =true;
tray->Visible=false;
}
catch (Exception &e) {
}
tray->Visible=true;
|
|
| Back to top |
|
 |
|