Board index » cppbuilder » Mouse Clicks

Mouse Clicks


2005-02-06 02:51:28 PM
cppbuilder80
I've overriden a controls WndProc where I'm listening for mouse
clicks because I want to add OnMouseDown, OnMouseUp and
OnDblClick events to the object.
My problem is that if I double click the object, WM_LBUTTONUP
is getting processed twice. If I comment out WM_LBUTTONUP,
WM_LBUTTONDBLCLK is properly detected. So ... it's a timing
issue.
How does one deal with this?
~ JD
 
 

Re:Mouse Clicks

"JD" < XXXX@XXXXX.COM >wrote in message
Quote

I've overriden a controls WndProc where I'm listening for mouse
clicks because I want to add OnMouseDown, OnMouseUp and
OnDblClick events to the object.

My problem is that if I double click the object, WM_LBUTTONUP
is getting processed twice. If I comment out WM_LBUTTONUP,
WM_LBUTTONDBLCLK is properly detected. So ... it's a timing
issue.

How does one deal with this?

~ JD
You could use a static variable to let you know.
void __fastcall TForm1::MyWndProc(Messages::TMessage &Message)
{
static unsigned int UpOrDown(WM_LBUTTONUP);
switch (Message.Msg)
{
case WM_LBUTTONDOWN:
Memo1->Lines->Add("LB Down") ;
UpOrDown = WM_LBUTTONDOWN;
break;
case WM_LBUTTONUP:
if (UpOrDown == WM_LBUTTONUP)
break;
Memo1->Lines->Add("LB Up");
UpOrDown = WM_LBUTTONUP;
break;
case WM_LBUTTONDBLCLK: Memo1->Lines->Add("LB Dbl Click");
};
OldWndProc(Message);
}
HTH
Simon.
 

Re:Mouse Clicks

"JD" < XXXX@XXXXX.COM >wrote in message
Quote
I've overriden a controls WndProc where I'm listening for
mouse clicks because I want to add OnMouseDown,
OnMouseUp and OnDblClick events to the object.
Controls already do all of that for you. TControl already has such events,
and the necessary message handlings to trigger them. The only thing you
have to do yourself, if anything, is to promote the existing events from
protected to published.
Quote
My problem is that if I double click the object,
WM_LBUTTONUP is getting processed twice.
As it should. That is normal message processing on Windows' part, and is
clearly documented by Microsoft as such:
Only windows that have the CS_DBLCLKS style can receive WM_LBUTTONDBLCLK
messages, which Windows generates whenever the user presses, releases, and
again presses the left mouse button within the system's double-click time
limit. Double-clicking the left mouse button actually generates four
messages: WM_LBUTTONDOWN, WM_LBUTTONUP, WM_LBUTTONDBLCLK, and WM_LBUTTONUP
again.
I've described this behavior before in terms of the VCL:
groups-beta.google.com/group/borland.public.cppbuilder.students/msg/24b79ce74eeaf310
Gambit
 

{smallsort}

Re:Mouse Clicks

"Remy Lebeau \(TeamB\)" < XXXX@XXXXX.COM >wrote:
Quote

[...] TControl already has such events, [...]
It's a non-visual object so I should be deriving from
TComponent right? I know that sounds wrong ... given that I
want mouse events but in reality I'm hooking into the form's
WndProc for WM_click messages.
Quote
I've described this behavior before in terms of the VCL:
That's enough info for me to be able to handle the problem.
Thank you.
~ JD