Announcement

Collapse
No announcement yet.

double-click on GRAPHIC WINDOW

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • double-click on GRAPHIC WINDOW

    Could someone tell me how to detect a double-click on a GRAPHIC window? Using the GRAPHIC WINDOW stuff that is. Thanks!

  • #2
    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

    Comment


    • #3
      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


      • #4
        Originally posted by Guy Dombrowski View Post
        ...it become evident that there is a time delay built in that function.
        Thanks Guy - I feel an email to [email protected] coming on.

        (later) OK I've reported it.
        Last edited by Chris Holbrook; 25 Oct 2008, 11:25 AM.

        Comment


        • #5
          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.
          You may alternately use SystemParametersInfo() function with either the SPI_GETDOUBLECLICKTIME or SPI_SETDOUBLECLICKTIME constants.

          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.
          You might want to try doing GRAPHIC WINDOW CLICK twice with a delay of the current system setting between tests.. something like...

          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
          ..
          I know this is incorrect logic but I think I have all the pieces there and they can be rearranged somehow to get desired result.

          MCM
          Last 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


          • #6
            Originally posted by Michael Mattias View Post
            The time to recognize a "double click" versus two "single clicks" is a System Parameters Setting.
            That value might be enough for Windows but is not enough for GRAPHIC WINDOW CLICK. On my PC it is 500, for me the threshold window for counting two clicks with movement is 600, without movement I have gone up to 5000 which is too long a delay to be practical, and still not got an accurate count, unless the mouse is moved between clicks. See code in post #2.

            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


            • #7
              Subclassing

              Anyway,
              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
              Old QB45 Programmer

              Comment


              • #8
                Originally posted by Guy Dombrowski View Post
                ...If you want to catch all 3 buttons and also mouse moves, you have to subclass...
                I know, but not now - my cup runneth over!

                Comment


                • #9
                  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
                  PB/CC 5 supports creating and subclassing windows.

                  For that matter, so did PB/CC 4, PB/CC 3, PB/CC 2 and PB/CC 1
                  Michael Mattias
                  Tal Systems (retired)
                  Port Washington WI USA
                  [email protected]
                  http://www.talsystems.com

                  Comment


                  • #10
                    Michael,

                    I believe Guy was referring to not having GRAPHIC commands for the 3 functions he desired all in PBCC5, so he would not have to subclass. He was not trying to say, as I read it, that subclassing was not possible in PBCC versions.
                    Rick Angell

                    Comment


                    • #11
                      Subclassing

                      Rick,

                      You are right, It would have been nice to have those in PBCC5 without having to subclass.
                      But I guess I will have to learn more Window programming in order to do what I want.
                      Old QB45 Programmer

                      Comment


                      • #12
                        You are right, It would have been nice to have those in PBCC5 without having to subclass
                        Send new feature suggestions directly to publisher at [email protected]
                        Michael Mattias
                        Tal Systems (retired)
                        Port Washington WI USA
                        [email protected]
                        http://www.talsystems.com

                        Comment


                        • #13
                          Originally posted by Chris Holbrook View Post
                          ...OK I've reported it.
                          reply today from Jeff Daniels, PowerBasic:

                          I have logged a request for the ability to catch double clicks from a graphic window.
                          That'll do for me!

                          Comment


                          • #14
                            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


                            • #15
                              Nsf

                              I also added my wish for full mouse control.
                              Old QB45 Programmer

                              Comment

                              Working...
                              X