VBA - Click mouse to change cursor to cross hair that spans the en
Gary,
Or if you only wish to track the mouse when a button is held down:
Dim MoveCrossHairs As Boolean
Private Sub UserForm_Initialize()
With lblHoriz
.Height = 1
.Left = 0
.Width = Me.Width
End With
With lblVert
.Width = 1
.Top = 0
.Height = Me.Height
End With
End Sub
Private Sub UserForm_MouseDown(ByVal Button As Integer, ByVal Shift As
Integer, ByVal X As Single, ByVal Y As Single)
If Button = xlPrimaryButton Then 'Or whichever button you wish to respond
to
MoveCrossHairs = True
lblHoriz.Top = Y
lblVert.Left = X
End If
End Sub
Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As
Integer, ByVal X As Single, ByVal Y As Single)
If MoveCrossHairs Then
lblHoriz.Top = Y
lblVert.Left = X
End If
End Sub
Private Sub UserForm_MouseUp(ByVal Button As Integer, ByVal Shift As
Integer, ByVal X As Single, ByVal Y As Single)
MoveCrossHairs = False
End Sub
NickHK
"gary" wrote in message
...
I need the ability to allow the user to change the cursor to a cross hair
that covers the entire form that detected the mouse event. This is needed
so
user can read values along sides and bottom of form as he/she moves mouse
over the form. I have been unable to find any vba code to do this.
Gary
|