I want to trap the mouse move event when the mouse is moving over any screen position EXCEPT over a specific control. Any ideas?
Printable View
I want to trap the mouse move event when the mouse is moving over any screen position EXCEPT over a specific control. Any ideas?
Do you want to Subclass the mouse event..
If you want to restrict the mouse move in a particular area on your form then you can try this..
use the following api in the MouseMove sub of your form
VB Code:
Private Declare Function SetCursorPos Lib "user32" (ByVal X As Long, ByVal Y As Long) As Long
Sorry I wasn't too clear in my previous post. It's not the mouse I want to trap to a specific area. Rather I want to trap the -shall I call it "screen.mousemove"?- event, i.e. I want some code to be triggered as soon as the mouse is no longer over a specific control, no matter where it goes to elsewhere on the screen.Quote:
Originally posted by pradeepkrao
Do you want to Subclass the mouse event..
[/Highlight]
So you want to do a Mouse Leave Event..
I had done some thing like this....
Copy the following Code
create a form and put some labels i.e. label control array..
run the program and move the mouse over the label and form.. see what happens..
VB Code:
Dim selected As Integer Dim i As Integer Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) selected = -1 For i = 0 To Label1.UBound Label1(i).FontBold = False Next End Sub Private Sub Label1_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single) If Index = selected Then Exit Sub For i = 0 To Label1.UBound Label1(i).FontBold = False Next Label1(Index).FontBold = True selected = Index End Sub
Well, that's closer to want I want, however the problem is I don't have an array of labels, rather a large number of controls of diferent types. I don't want to write code for the mousemove event of each and every one of these controls, you see what I mean?Quote:
Originally posted by pradeepkrao
So you want to do a Mouse Leave Event..
I had done some thing like this....
Copy the following Code
create a form and put some labels i.e. label control array..
run the program and move the mouse over the label and form.. see what happens..[/Highlight]
The idea is, as it were, to simulate a "mouse_not_move" subroutine for that special control.