🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Trapping button message

#14816
From: Remy Lebeau (TeamB)
Date: Wed, 30 Jul 2003 16:31
36 lines
2201 bytes
"Vladimir Afanasyev" <avv@systema.kiev.ua> wrote in message
news:3f27c07b$1@newsgroups.borland.com...

>          TPoint click=Form1->ScreenToClient(Msg.pt);
>          TControl* cntrl=Form1->ControlAtPos(click,False,False);

You do not need to, nor should you, use the global form pointer.  Since you
are already inside the form anyway, just use the implicit 'this' pointer
instead:

    TPoint click = ScreenToClient(Msg.pt);
    TControl* cntrl = ControlAtPos(click, false, false);

Or

    TPoint click = this->ScreenToClient(Msg.pt);
    TControl* cntrl = this->ControlAtPos(click, false, false);

>          if(SpeedButton1 ==
dynamic_cast<TSpeedButton*>(cntrl))ShowMessage("Button event catched!");

For what is being asked, do not compare the dynamic_cast to a particular
pointer, just test whether it succeeded at all:

    if(dynamic_cast<TSpeedButton*>(cntrl))
        ShowMessage("Button event catched!");

> void __fastcall TForm1::FormCreate(TObject *Sender)

Do not use the OnCreate event in C++.  It is a Delphi remnant that does not
work correctly in C++ as it can be called before the constructor, which is
illegal in C++.  Use the constructor instead.


Gambit
Technical Details
Message-ID: <3f27f2ed@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-06!sn-xit-09!supernews.com!newshosting.com!news-xfer1.atl.newshosting.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail
References: <3f26ea7c$1@newsgroups.borland.com> <3f27c07b$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,77c37ce9ffa755d1
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-07-30 09:40:02 PST
From: "Remy Lebeau \(TeamB\)" <gambit47@yahoo.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References:  <3f26ea7c$1@newsgroups.borland.com> <3f27c07b$1@newsgroups.borland.com>
Subject: Re: Trapping button message
Date: Wed, 30 Jul 2003 09:31:14 -0700
Lines: 38
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
NNTP-Posting-Host: 207.175.226.26
Message-ID: <3f27f2ed@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1059582701 207.175.226.26 (30 Jul 2003 09:31:41 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-06!sn-xit-09!supernews.com!newshosting.com!news-xfer1.atl.newshosting.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail