CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Mouse Buttons

  1. #1
    Join Date
    Oct 1999
    Posts
    15

    Mouse Buttons

    All,

    Is there an API call for what mouse buttons are down and which ones are up? I know there is mousedown events in Visual Basic, but I don't want to make an event for everything if my program. I need to know if the left mouse button is down and if the right mouse buttons is down or both. Can somebody please help me?

    Xemion




  2. #2
    Join Date
    Dec 1999
    Location
    Israel
    Posts
    101

    Re: Mouse Buttons

    You can use API Function GetAsyncKeyState(), with
    VK_LBUTTON for left mouse button,
    VK_RBUTTON for right mouse button
    and VK_MBUTTON for middle mouse button,
    which will give you the mouse status (which key pressed or released).

    You can also check in Key_Down and Key_Up Events for
    vbKeyLButton, vbKeyRButton and bvKeyMButton constants, so you don't need API.

    Good Luck!


  3. #3
    Join Date
    Oct 1999
    Posts
    15

    Re: Mouse Buttons

    Thanks!!

    Xemion


  4. #4
    Join Date
    Oct 1999
    Posts
    15

    Re: Mouse Buttons

    Ruth,

    I have another question. Sometimes GetAynscKeyState isn't picking up my mouse clicks. I've got it check for clicks in a do loop,
    sometimes is misses clicks. Would this be because the mouse button is down while it's checking for clicks? I don't understand why it's skipping them. Can you help?

    Xemion



  5. #5
    Join Date
    Dec 1999
    Location
    Israel
    Posts
    101

    Re: Mouse Buttons

    It could depend on the speed of your Mouse Driver and on the speed of your Loop.
    If you check the Mouse Status slower than it changes it you could miss something.
    It also depend on the priority of your application, and, of course, on the Operating
    System. To be sure that everything is OK, try to remember that
    GetAsyncKeyState returns you 0 if mouse or key didn't pressed, 80 if it was pressed
    once, 81 if it was pressed continuously and 1 if it was pressed and released.

    Good Luck


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

Featured