 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Bob Byers Guest
|
Posted: Mon May 21, 2007 2:50 am Post subject: TTrayIcon anomalies |
|
|
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 |
|
 |
|
|
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
|
|