|
-
Nov 2nd, 2001, 02:49 AM
#1
Thread Starter
Junior Member
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.
-
Nov 2nd, 2001, 08:45 AM
#2
Try using the GetCursorPos API function.
VB Code:
Private Declare Function GetCursorPos Lib "user32" _
(lpPoint As POINTAPI) As Long
Private Type POINTAPI
x As Long
y As Long
End Type
Private Sub Command1_Click()
Dim PT As POINTAPI
GetCursorPos PT
MsgBox "(" & PT.x & "," & PT.y & ")"
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|