🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Trapping button message

#14803
From: Mattias Carleson
Date: Wed, 30 Jul 2003 11:36
37 lines
2314 bytes
Sorry, was a little quick answering. Now it works trapping WM_COMMAND from
TButton
and TBitBtn i WndProc. In Application->OnMessage it doesnt work, but never
mind. But I
still whant to trap the message when the user clicks a TSpeedButton. The
TSpeedButton is placed
in a TToolBar or a TCoolBar, Ive tried both.

> WM_COMMAND only applies to windowed controls, which TSpeedButton is not.
> What you are attempting to do would apply for TButton or TBitBtn, but not
> TSpeedButton.

Ok, so I wrote the following code. It works, almost.

void __fastcall TForm1::WndProc(TMessage& Msg)
{
   if(Msg.Msg == WM_LBUTTONDOWN)
   {
        ShowMessage("Left mousebtn trapped in WndProc!");
    }
}

There is just one problem. When the form shows for the first time, clicking
on the speedbutton or the
toolbar/coolbar doesnt generate any WM_LBUTTONDOWN. First I have to click
somewhere on
the mainforms client area. Doing that generates the message, and after that
clicking the speedbutton
does too. What is the logic and how can I make it generate the message at
once?

A second question. I need to detect which speedbutton generating the
message. Do I have to use the
TControl::ClientToScreen() function and compare coordinates?

Thankyou
/Mattias
Technical Details
Message-ID: <3f27ad3f$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-09!supernews.com!news.maxwell.syr.edu!news-out1.nntp.be!propagator2-sterling!news-in-sterling.nuthinbutnews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail
References: <3f26ea7c$1@newsgroups.borland.com> <3f26efb2$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 04:37:45 PST
From: "Mattias Carleson" <mattias.carleson@commentor.se>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <3f26ea7c$1@newsgroups.borland.com> <3f26efb2$1@newsgroups.borland.com>
Subject: Re: Trapping button message
Date: Wed, 30 Jul 2003 13:36:08 +0200
Lines: 39
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
NNTP-Posting-Host: 194.71.186.117
Message-ID: <3f27ad3f$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1059564863 194.71.186.117 (30 Jul 2003 04:34:23 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-09!supernews.com!news.maxwell.syr.edu!news-out1.nntp.be!propagator2-sterling!news-in-sterling.nuthinbutnews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail