Results 1 to 2 of 2

Thread: Getting Mouse Status

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2001
    Location
    Near Sheerness in Kent, UK
    Posts
    25

    Exclamation Getting Mouse Status

    I am trying to get hold of the mouse X,Y coords and button status. However, it is not in response to a mouse click or mouse
    move event. I’m operating from inside my own apps main window, however I have a large array of dynamic objects, e.g. Labels, Shapes and Bitmap Images. Shapes register the mouse, so I can work out what shape I’m clicking on. However, with labels, I have no control of the mouse when its located inside the label (unless the label is not enabled). I therefore want a
    generic mouse status routine that could be called from within a timer. I don't think its possible to use the WithEvents
    statement, because of the way the system has been set-up. I have a user defined type with my object arrays inside.
    WithEvents cannot be used outside of a module. I would never of had the same problem under 'C/C++', but VB is event driven,
    hence the problem. Is there any way I can use WithEvents or some other method to access the mouse under the above circumstances?

    Sample source code would be greatly appreciated.
    Shaun Pudwell.

  2. #2
    Matthew Gates
    Guest
    Try using the GetCursorPos API function.


    VB Code:
    1. Private Declare Function GetCursorPos Lib "user32" _
    2. (lpPoint As POINTAPI) As Long
    3.  
    4. Private Type POINTAPI
    5.     x As Long
    6.     y As Long
    7. End Type
    8.  
    9. Private Sub Command1_Click()
    10.     Dim PT As POINTAPI
    11.     GetCursorPos PT
    12.     MsgBox "(" & PT.x & "," & PT.y & ")"
    13. End Sub

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