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 

TTrayIcon anomalies

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (IDE)
View previous topic :: View next topic  
Author Message
Bob Byers
Guest





PostPosted: Mon May 21, 2007 2:50 am    Post subject: TTrayIcon anomalies Reply with quote



I've got a program that I need to have show an icon in the system tray
and nothing in the taskbar. I've done this before with BCB6, but an
having a problem with BDS. So, I removed all of the Windows code from
the app and tried using the new TTrayIcon, which does simplify the
process a lot.

Here's the problem. I double click the icon and the program displays as
it is supposed to. I click the minimize button and the program
disappears as it is supposed to ... ONCE. The next time I double click
the icon, the program appears again (but if it's hidden behind another
app, it stays there and doesn't move to the foreground). I minimize the
covering app and click the minimize button ... nothing happens. And,
the OnMinimize event doesn't seem to fire. On the third and all
subsequent double clicks, the program will appear and move to the
foreground, but I still can't use the minimize button.

Here's the relevent code

In the constructor, I have
Application->OnMinimize = AppOnMinimize;
Application->OnRestore = AppOnRestore;

Then there are the methods
//---------------------------------------------------------------------------
void __fastcall TMainForm::FormClose(TObject *Sender, TCloseAction &Action)
{
// This application closes to the system tray. When they push
// close, hide the app, but don't let the program close.
if(!CanClose)
{
AppOnMinimize(this);
Action = caNone;
}
else
snip .....
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::AppOnMinimize(TObject *Sender)
{
Application->MainForm->Visible = false;
ShowWindow(Application->Handle, SW_HIDE);
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::AppOnRestore(TObject *Sender)
{
Application->MainForm->Visible = true;
ShowWindow(Application->Handle, SW_SHOW);
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::TrayIconDblClick(TObject *Sender)
{
AppOnRestore(this);
}
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (IDE) 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.