Announcement

Collapse
No announcement yet.

How to get left/right mouse click?

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

  • How to get left/right mouse click?

    Have this wee routine working but only with left click.... Question is how to detect which mouse button was pressed?

    Code:
    5500 '-- Get mouse position in current screen hWin02 and see if mouse been clicked
    5510 LOCAL CCP        AS POINT
    5520 LOCAL g          AS LONG
    5530 LOCAL clicked_x  AS LONG
    5540 LOCAL clicked_y  AS LONG
    5550 :
    5560 GetCursorPos CCP'                                             get Current Cursor Position on desktop
    5570 ScreenToClient(hWin02,CCP)'                                   get Current Cursor Position in Client's space
    5580 :
    5590 CurrMouseHoriz&=CCP.x'                                        get Mouse current Horiz position
    5600 CurrMouseVert& =CCP.y'                                        get Mouse current Vert  position
    5610 :
    5620 GRAPHIC WINDOW CLICK TO g, clicked_x, clicked_y'              get clicked positions
    5630 IF ISFALSE g THEN 6900'                                       mouse was NOT clicked
    5640 ?"Mouse was clicked at "+STR$(clicked_x)+","+STR$(clicked_y)' dio
    5650 :
    5660 '-- do all of the clicked tasks in here....
    5670 :
    6890 :
    6900 RETURN

  • #2
    Maybe can use GetAsyncKeyState to see if right button is/was pressed, something like:
    Code:
      IF (GetAsyncKeyState(%VK_RBUTTON) AND &H8000) THEN g = 2  ' whatever..
    Guess you'll need to use GetCursorPos, etc, to get coordinates for clicked_x, clicked_y.

    Comment


    • #3
      You could change to a control other than the PB GRAPHICS control/window and subclass it looking for WM_LBUTTONUP or WM_RBUTTONUP.

      Heck, maybe you could event subclass a graphic control or window and look for those.

      Note, will only work if the control has the keyboard focus.
      Michael Mattias
      Tal Systems Inc.
      Racine WI USA
      mmattias@talsystems.com
      http://www.talsystems.com

      Comment


      • #4
        Originally posted by Borje Hagsten View Post
        Maybe can use GetAsyncKeyState to see if right button is/was pressed, something like:
        Code:
        IF (GetAsyncKeyState(%VK_RBUTTON) AND &H8000) THEN g = 2 ' whatever..
        Guess you'll need to use GetCursorPos, etc, to get coordinates for clicked_x, clicked_y.
        Fantastic... nice and simple. Many thanks Borje.

        Comment

        Working...
        X