Results 1 to 5 of 5

Thread: Left Click

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 1999
    Posts
    5

    Post

    How can I make the click event code of a label execute only to a left mouse click? And I dont want to put the code in the mouse up and mouse down events.

  2. #2
    Lively Member
    Join Date
    Jan 1999
    Location
    Burlington, IA, USA`
    Posts
    77

    Post

    Use mouse_down event'

    'If button = 2 then
    'do whatever
    end if

  3. #3
    Hyperactive Member
    Join Date
    Jul 1999
    Location
    NY, USA
    Posts
    270

    Post

    You are gonna have to use MouseDown or MouseUp... My Recommendation:

    Code:
    Private Sub Label1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Select Case Button
         Case 1 'LEFT MOUSE BUTTON
              MsgBox "Left Mouse Button Pressed"
         Case 2 'RIGHT MOUSE BUTTON
              MsgBox "Right Mouse Button Pressed"
    End Select
    End Sub



    ------------------
    Tom Young, 14 Year Old
    tyoung@stny.rr.com
    ICQ: 15743470
    AIM: TomY10
    PERL, JavaScript and VB Programmer

  4. #4
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,175

    Post

    You should use VB's built in constants rather than "magic numbers" like 1 and 2, so substitute vbRightButton and vbLeftButton. They're self-documenting.

    ------------------
    Marty

  5. #5
    Lively Member
    Join Date
    Jun 1999
    Location
    Ireland
    Posts
    96

    Post

    You can use the MouseClick Event, but some extra code is needed,

    Declare the following function to get all keys pressed (including mouse buttons)

    Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer

    Private Sub Label1_Click
    If GetAsyncKeyState(lngKeyToCheck) <> 0 then
    'Do what you want
    EndIf
    End Sub

    Replace "lngKeyToCheck" with the code const for the key you want to check for. In this case the Left Mouse Key.

    Hope this helps,

    Steve.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width