BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to refresh the systemtray TrayIcon after explorer crash

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Usage)
View previous topic :: View next topic  
Author Message
Julien Moorrees
Guest





PostPosted: Sun Jan 25, 2004 11:25 am    Post subject: How to refresh the systemtray TrayIcon after explorer crash Reply with quote



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





PostPosted: Sun Jan 25, 2004 1:51 pm    Post subject: Re: How to refresh the systemtray TrayIcon after explorer cr Reply with quote



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





PostPosted: Sun Jan 25, 2004 6:46 pm    Post subject: Re: How to refresh the systemtray TrayIcon after explorer cr Reply with quote



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





PostPosted: Sun Jan 25, 2004 10:42 pm    Post subject: Re: How to refresh the systemtray TrayIcon after explorer cr Reply with quote


"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





PostPosted: Wed Mar 03, 2004 3:36 pm    Post subject: Re: How to refresh the systemtray TrayIcon after explorer cr Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Usage) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.