Could someone tell me how to detect a double-click on a GRAPHIC window? Using the GRAPHIC WINDOW stuff that is. Thanks!
Announcement
Collapse
No announcement yet.
double-click on GRAPHIC WINDOW
Collapse
X
-
Trying a loop around GRAPHIC WINDOW CLICK, I found that to get a count of 2 clicks I had to click three times or more. But increasing the sampling window I found that two actual clicks could be recorded as such providing that there was mouse movement in between the clicks.
So GRAPHIC WINDOW CLICK seems to ignore successive clicks in the same place, which makes detection a double-click rather difficult.
Anyone?
Code:#COMPILE EXE #DIM ALL #INCLUDE "WIN32API.INC" FUNCTION PBMAIN () AS LONG LOCAL clicked, clickX, clickY, clickcount, lstart, lend AS LONG LOCAL hGW AS DWORD LOCAL skey AS STRING GRAPHIC WINDOW "counting clicks", 300, 300, 200, 200 TO hGW GRAPHIC ATTACH hGW, 0 GRAPHIC PRINT "click mouse, watch count" GRAPHIC PRINT "ESC to exit" WHILE 1 = 1 clickcount = 0 clicked = 0 lstart = gettickcount lend = lstart + 5000 WHILE gettickcount < lend GRAPHIC WINDOW CLICK TO clicked, clickX, clickY IF clicked THEN INCR clickcount clicked = 0 END IF WEND GRAPHIC SET POS (50, 50) GRAPHIC PRINT STR$(clickcount) + " clicks detected" WEND GRAPHIC WINDOW END ' END FUNCTION
-
Double click
Chris,
I simplified your double click demo to try to better illustrate the failure to detect a double click.
If you start clicking slowly and increase progressively the tempo, it become evident that there is a time delay built in that function.
If you do it while moving the mouse around, it can catch rapid click but you would have to add a timing loop to detect a double click.
Conclusion, you need to subclass the mouse handling to use it when writing graphic code like I did in my Graphic Console Demo.
Code:#COMPILE EXE #CONSOLE OFF #DIM ALL FUNCTION PBMAIN () AS LONG LOCAL clicked, clickX, clickY, clickcount AS LONG LOCAL hGW AS DWORD: LOCAL skey AS STRING GRAPHIC WINDOW "counting clicks", 300, 300, 600, 600 TO hGW GRAPHIC ATTACH hGW, 0 GRAPHIC PRINT "click mouse, watch count. Esc or [x] to exit" WHILE skey<>CHR$(27) GRAPHIC GET DC TO hgw: IF hgw=0 THEN END GRAPHIC WINDOW CLICK TO clicked, clickX, clickY IF clicked THEN INCR clickcount GRAPHIC SET POS (50, 50): GRAPHIC PRINT STR$(clickcount) + " clicks detected" GRAPHIC INKEY$ TO skey WEND GRAPHIC WINDOW END END FUNCTION
Old QB45 Programmer
Comment
-
Originally posted by Guy Dombrowski View Post...it become evident that there is a time delay built in that function.
(later) OK I've reported it.Last edited by Chris Holbrook; 25 Oct 2008, 11:25 AM.
Comment
-
The time to recognize a "double click" versus two "single clicks" is a System Parameters Setting.
Direct WinAPI functions:
GetDoubleClickTime Function
--------------------------------------------------------------------------------
The GetDoubleClickTime function retrieves the current double-click time for the mouse. A double-click is a series of two clicks of the mouse button, the second occurring within a specified time after the first. The double-click time is the maximum number of milliseconds that may occur between the first and second click of a double-click.
[....]
SetDoubleClickTime Function
--------------------------------------------------------------------------------
The SetDoubleClickTime function sets the double-click time for the mouse. A double-click is a series of two clicks of a mouse button, the second occurring within a specified time after the first. The double-click time is the maximum number of milliseconds that may occur between the first and second clicks of a double-click.
Reading the doc...
GRAPHIC WINDOW CLICK checks whether the specified GRAPHIC WINDOW has been clicked since the last time this statement was executed on this window.
Code:FUNCTION WasDoubleClicked (hWin AS LONG) AS LONG LOCAL dwDTTime AS LONG dwDTTime = GetDoubleClickTime() GRAPHIC WINDOW CLICK hWin TO click&, X, Y SLEEP dwDtTime GRAPHIC WINDOW CLICK hWnd TO Click&, X, Y FUNCTION = (Click& = 1) ' window WAS clicked since last time this window was clicked ..
MCMLast edited by Michael Mattias; 25 Oct 2008, 12:02 PM.Michael Mattias
Tal Systems (retired)
Port Washington WI USA
[email protected]
http://www.talsystems.com
Comment
-
Originally posted by Michael Mattias View PostThe time to recognize a "double click" versus two "single clicks" is a System Parameters Setting.
Its as if there was some debouncing going on inside PBCC using a longer time interval than doubleclicktime, but - who knows.
For the time being, I will live with it pending PB's reply. If pressed I can subclass the control etc etc like Guy has done.
Comment
-
If you want to catch all 3 buttons and also mouse moves, you have to subclass.
Would have been nice to have those in PBCC5
For that matter, so did PB/CC 4, PB/CC 3, PB/CC 2 and PB/CC 1Michael Mattias
Tal Systems (retired)
Port Washington WI USA
[email protected]
http://www.talsystems.com
Comment
-
You are right, It would have been nice to have those in PBCC5 without having to subclassMichael Mattias
Tal Systems (retired)
Port Washington WI USA
[email protected]
http://www.talsystems.com
Comment
-
PB is really good about acknowledging NFSs.
It's nice to know know someone is going to look at your suggestion on "Let's pick the features for the next release" days in Venice FL.Michael Mattias
Tal Systems (retired)
Port Washington WI USA
[email protected]
http://www.talsystems.com
Comment
Comment