Advertisement

Double clicking

Started by May 21, 2000 06:29 PM
7 comments, last by Possibility 24 years, 7 months ago
Hey, I have a TBS game I am working on, with alot of it done. But for a feature of my game, I need to use double-clicking, and I was wondering if there is a windows message handler for it. I am not using a directX mouse, but rather a non-exclusive windows mouse. I looked through SDK, and didnt find anything. So what I was wondering is, is there way to use the windows double clicking, and that is would use windows settings for double clicking (you know in windows you can set your double click speed). Is there way to access that in a game? I currently use this: LRESULT CALLBACK WindowProc (HWND hWnd, unsigned uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_MOUSEMOVE: case WM_LBUTTONDOWN: case WM_LBUTTONUP: case WM_RBUTTONDOWN: case WM_RBUTTONUP: but is there another one for double clicking, or do I have to just create it manually on my own (which I can do if needed). Possibility
WM_LBUTTONDBLCLICK
Advertisement
Yeah,
anonymous dude is right, except he had a little typo, as the right WM is :
WM_LBUTTONDBLCLK

and not "CLICK" on the end. Uhm, unless both are valid, not sure.

Cya,
-RoTTer
Oh sweet, thanks, I figured there would be something like that.

While I was thinking about this before, and thinking of a way to do it manually, I was wondering how to prevent a 'single click' action from occuring when a user does a double click. My game runs through the main game loop at over 60 times per second. And user cant do 2 mouse button clicks in less time then that. So, when he does do a double click, the first click will be handled seperately by the game, and 2 actions would end up happening, first, the single click action, and then the double. So how do you prevent that from happening when the user does a double click, and just the doulble click action occurs?

Possibility

Edited by - Possibility on May 22, 2000 2:47:28 AM
windows sends it messages in this order, for a double click:

mouse down
click
mouse up
double click
mouse down
mouse up

I can''t think of a "good" way to do it off the top of my head, you can try using a windows timer, and some flags, to determine what handler to call, if any.

on the mouseup, see if a flag named, say, LASTUP is set. If it is, unset it, otherwise, start a timer, with about a 750ms or so interval.

on doubleclick, set a flag called DOUBLECLICK.

in the timer event:
deactivate the timer.
if DOUBLECLICK is set:
* set LASTUP
* clear DOUBLECLICK
* call your doubleclick code
otherwise, call your single click code.

Not sure how well that will work. If your process uses a lot of CPU in the main thread, the timer could be REALLY inaccurate, the timer event may even not fire.

oops, I''m stupid, don''t set LASTUP in the timer event, set it before you activate the timer in mouseup. Like this:

LASTUP:= NOT LASTUP
if LASTUP then ActivateTimer()
Advertisement
I''m a complete idiot. IGNORE THE ABOVE POST.
In double click, SET LASTUP, instead of in the timer. Everything else is the same as the original post. Duh.
I don''t know if you are doing this or not, but you need to set the window class''s style to allow double-click messages. You do this with the CS_DBLCLKS flag.


- null_pointer
Sabre Multimedia
Thanks guys, I will do that.

Possibility

This topic is closed to new replies.

Advertisement