🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #4508

Re: Receiving NIN_BALLOONUSERCLICK from system tray balloon

#4508
From: Kris
Date: Thu, 19 Jan 2006 11:55
72 lines
3524 bytes
On 17 Jan 2006 11:24:26 -0700, "JD" <nospam@nospam.com> wrote:
>    http://groups.google.com/group/borland.public.cppbuilder.vcl.components.using/msg/57af11b9a35689b0

JD, 

Unfortunately I'm having some problems integrating your TrayIcon code
into my actual project. 

class TMainForm : public TForm 
{ 
public:                 
   class TAnimatedTrayIcon *MySystemTray; 
   void __fastcall MyBalloonClick(TObject *Sender); 
   ... 
} 

void __fastcall TMainForm::MyBalloonClick(TObject *Sender) 
{ 
   Caption="Click"; 
} 

void __fastcall TMainForm::FormCreate(TObject *Sender) 
{ 
   MySystemTray=new TAnimatedTrayIcon(this); 
   MySystemTray->ImageList=SysTrayImageList; 
   MySystemTray->StaticIndex=NEUTRAL_AGENT; // =0 
   MySystemTray->BalloonIconType=itInformation; 
   MySystemTray->OnBalloonClick=MyBalloonClick; 
   MySystemTray->BalloonCaption="Caption"; 
   MySystemTray->BalloonText="Text"; 
   MySystemTray->Active=true; 
} 

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(); 
   } 
Which is then followed by an access violation. 

However, TMainForm is auto-created and assigned to be the MainForm. 
The line of code triggering this error is this one : 
MySystemTray->BalloonText="Click here to download these updates."; 
Leaving out this line causes the app to work with systray icon, but
without balloons. 
However, closing the app still results in an access violation. 

I changed the first line into : 
MySystemTray=new TAnimatedTrayIcon(Application->MainForm); 
But this resulted in following error : 
if( !Owner ) throw Exception("You must assign an Owner."); 


The TrayIcon does work fine when I ommit the balloon code : 
   MySystemTray=new TAnimatedTrayIcon(this); 
   MySystemTray->ImageList=SysTrayImageList; 
   MySystemTray->StaticIndex=NEUTRAL_AGENT; 
   MySystemTray->Active=true; 

I've disabled my own code as much as possible in the
FormCreate/FormClose to eliminate the possibility that my own code is
somehow messing things up, but even then the problems remain as soon
as I start using the balloon. 

I've initially played with the TrayIcon and its balloons on an empty
project with just a single form and this worked great. However, if I
integrate it into my current project things start going wrong and I
haven't got a clue on what is going wrong. 

Any help is VERY much appreciated. 
Technical Details
Message-ID: <sbvus1dar7gqt1fveg6ep774hn6g7l8vt1@4ax.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.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
References: <0dbqs15pnttts94lrl0gfkv1qmdi5r7v2g@4ax.com> <43cd446a$1@newsgroups.borland.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: Kris <x.y@xyz.xx>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: Receiving NIN_BALLOONUSERCLICK from system tray balloon
Date: Thu, 19 Jan 2006 12:55:13 +0100
Message-ID: <sbvus1dar7gqt1fveg6ep774hn6g7l8vt1@4ax.com>
References: <0dbqs15pnttts94lrl0gfkv1qmdi5r7v2g@4ax.com> <43cd446a$1@newsgroups.borland.com>
X-Newsreader: Forte Free Agent 3.1/32.783
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 81.11.238.166
X-Trace: newsgroups.borland.com 1137671545 81.11.238.166 (19 Jan 2006 03:52:25 -0700)
Lines: 72
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.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