🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Receiving NIN_BALLOONUSERCLICK from system tray balloon

#4512
From: Kris
Date: Thu, 19 Jan 2006 17:11
69 lines
3070 bytes
On 19 Jan 2006 06:03:23 -0700, "JD" <nospam@nospam.com> wrote:
>Use the constructor and destructor instead.

Thanks for your feedback.

Moving the code to the constructor does solve the "TAnimatedTrayIcon
can only be placed on the Main Form"-error.

Unfortunately not all problems are solved. Now I still run into an
'access violation' exception as soon as I define the balloon members.

__fastcall TMainForm::TMainForm(TComponent* Owner) : TForm(Owner)
{
  MySystemTray=new TAnimatedTrayIcon(this);
  MySystemTray->ImageList=SysTrayImageList;
  MySystemTray->StaticIndex=NEUTRAL_AGENT;
  MySystemTray->StaticHint="xxxx"; 
  MySystemTray->BalloonIconType=itInformation;
  MySystemTray->OnBalloonClick=MyBalloonClick;
  MySystemTray->BalloonText="Text";
  MySystemTray->BalloonCaption="Caption";
  MySystemTray->Active=true;
}

The debugger shows the offending line in  system.pas (I've marked it
with ##### down below). Don't know if the code below is useful but
just be safe I posted it too even though the lay-out turns out to be a
bit messy.

procedure _LStrClr(var S);
{$IFDEF PUREPASCAL}
var
  P: PStrRec;
begin
  if Pointer(S) <> nil then
  begin
    P := Pointer(Integer(S) - Sizeof(StrRec));
    Pointer(S) := nil;
    if P.refCnt > 0 then
      if InterlockedDecrement(P.refCnt) = 0 then
        FreeMem(P);
  end;
end;
{$ELSE}
asm
  { ->    EAX pointer to str      }

  MOV     EDX,[EAX]                       { fetch str }
  TEST    EDX,EDX                         { if nil, nothing to do }
  JE      @@done
  MOV     dword ptr [EAX],0               { clear str }
  
  ####################################
  MOV     ECX,[EDX-skew].StrRec.refCnt    { fetch refCnt }
  ####################################
      
  DEC     ECX                             { if < 0: literal str }
  JL      @@done
  LOCK DEC     [EDX-skew].StrRec.refCnt        { threadsafe dec
refCount       }
  JNE     @@done
  PUSH    EAX
  LEA     EAX,[EDX-skew].StrRec.refCnt    { if refCnt now zero,
deallocate}
  CALL    _FreeMem
  POP     EAX
@@done:
end;
{$ENDIF}
Technical Details
Message-ID: <jbhvs15q97pv7bgmpfdip6h6fuqucr1h5c@4ax.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news3.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <0dbqs15pnttts94lrl0gfkv1qmdi5r7v2g@4ax.com> <43cd446a$1@newsgroups.borland.com> <sbvus1dar7gqt1fveg6ep774hn6g7l8vt1@4ax.com> <43cf9c2b$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 18:11:31 +0100
Message-ID: <jbhvs15q97pv7bgmpfdip6h6fuqucr1h5c@4ax.com>
References: <0dbqs15pnttts94lrl0gfkv1qmdi5r7v2g@4ax.com> <43cd446a$1@newsgroups.borland.com> <sbvus1dar7gqt1fveg6ep774hn6g7l8vt1@4ax.com> <43cf9c2b$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 1137690525 81.11.238.166 (19 Jan 2006 09:08:45 -0700)
Lines: 70
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news3.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail