Article View: borland.public.cppbuilder.nativeapi
Article #14814Re: Trapping button message
From: Remy Lebeau (TeamB)
Date: Wed, 30 Jul 2003 16:27
Date: Wed, 30 Jul 2003 16:27
45 lines
3005 bytes
3005 bytes
"Mattias Carleson" <mattias.carleson@commentor.se> wrote in message news:3f27ad3f$1@newsgroups.borland.com... > Now it works trapping WM_COMMAND from > TButton and TBitBtn i WndProc. In > Application->OnMessage it doesnt work That is because the OnMessage event is only triggered for messages that are posted into the message queue. WM_COMMAND is not a posted message. It is sent directly to the window procedure of the destination window without going through the message queue at all. > But I still whant to trap the message when the user > clicks a TSpeedButton There is no such message for clicking a TSpeedButton because TSpeedButton is not a true button to begin with. It is a graphical control that simulates a button. It doesn't even have a window of its own. That is what I was trying to explain to you earlier. You'll have to process the individual mouse up/down messages instead. > Ok, so I wrote the following code. It works, almost. <snip> > 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. You are trying to intercept the message at the form level, but such messages are not sent to the form unless you are clicking on the form itself. Otherwise, they are sent to the TSpeedButton directly. Not all messages go through a parent window first. For what you are trying to do, you will have to subclass the TSpeedButton directly. > A second question. I need to detect which > speedbutton generating the message. Since such messages to not provide any HWND specifying the target window, then you will just have to translate the screen coordinates to client coordinates and then enumerate the components looking for the component that cooresponds to those coordinates. Have a look at the TWinControl::ControlAtPos() method. You may have to call it recursively, depending on your design. Gambit
Technical Details
Message-ID:
<3f27f08b@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!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-mailReferences:
<3f26ea7c$1@newsgroups.borland.com> <3f26efb2$1@newsgroups.borland.com> <3f27ad3f$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:29:43 PST From: "Remy Lebeau \(TeamB\)" <gambit47@yahoo.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <3f26ea7c$1@newsgroups.borland.com> <3f26efb2$1@newsgroups.borland.com> <3f27ad3f$1@newsgroups.borland.com> Subject: Re: Trapping button message Date: Wed, 30 Jul 2003 09:27:19 -0700 Lines: 47 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: <3f27f08b@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1059582091 207.175.226.26 (30 Jul 2003 09:21:31 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!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