Article View: borland.public.cppbuilder.nativeapi
Article #4510Re: Receiving NIN_BALLOONUSERCLICK from system tray balloon
From: JD
Date: Thu, 19 Jan 2006 13:03
Date: Thu, 19 Jan 2006 13:03
55 lines
2779 bytes
2779 bytes
Kris <x.y@xyz.xx> wrote:
>
> [...] problems integrating your TrayIcon
<snip>
>void __fastcall TMainForm::FormCreate(TObject *Sender)
Never use the OnCreate or OnDestroy events. They are Delphi
remnants and as such can execute out of order. Use the
constructor and destructor instead. For the destructor, you
need to prototype it in the header. For example:
public: // User declarations
__fastcall TForm1(TComponent* Owner); // don't duplicate
__fastcall ~TForm1();
//-------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner)
{
// initialization code here
}
//-------------------------------------------------------------
__fastcall TForm1::~TForm1()
{
// clean-up code here
}
//-------------------------------------------------------------
>Following error code is executed when I run it :
> if( FParentForm != Application->MainForm )
> {
> MessageDlg( "TAnimatedTrayIcon can only be placed on the Main
>Form.", mtError, TMsgDlgButtons() << mbOK, 0 );
> Application->Terminate();
> }
The only way that that block of code is reached is if the
main form is not the Owner of the object (which I see that it
is) or if the Application::MainForm has not been set yet as a
result of the constructor not finishing. I used PostMessage to
delay that if-block until MainForm was valid but it appears
that OnCreate is mucking it up.
<snip>
All of the problems that you describe are in my mind a direct
result of using OnCreate.
> I've disabled my own code as much as possible in the
> FormCreate/FormClose
FormClose is not guaranteed to execute and if it's used for
clean-up can cause problems. Use the destructor instead.
~ JD
Technical Details
Message-ID:
<43cf9c2b$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<0dbqs15pnttts94lrl0gfkv1qmdi5r7v2g@4ax.com> <43cd446a$1@newsgroups.borland.com> <sbvus1dar7gqt1fveg6ep774hn6g7l8vt1@4ax.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,2165941223f42fca X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: "JD" <nospam@nospam.com> Sender: "JD" <nospam@nospam.com> Reply-To: "JD" <nospam@nospam.com> Subject: Re: Receiving NIN_BALLOONUSERCLICK from system tray balloon Newsgroups: borland.public.cppbuilder.nativeapi X-User-Info: 152.163.100.201 X-Forwarded-For: 172.147.103.100 References: <0dbqs15pnttts94lrl0gfkv1qmdi5r7v2g@4ax.com> <43cd446a$1@newsgroups.borland.com> <sbvus1dar7gqt1fveg6ep774hn6g7l8vt1@4ax.com> NNTP-Posting-Host: 207.105.83.66 Message-ID: <43cf9c2b$1@newsgroups.borland.com> Date: 19 Jan 2006 06:03:23 -0700 X-Trace: newsgroups.borland.com 1137679403 207.105.83.66 (19 Jan 2006 06:03:23 -0700) Lines: 56 Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail