What would be the code for any size of button to keep the cursor off of it?
Printable View
What would be the code for any size of button to keep the cursor off of it?
you mean having cursor avoiding that area? Use Setcursorpos api to move cursor
well I sorta wanted the code, the button in the size of 6 of those little dots on the form.
Try something like this:
Code:Private Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
Private Declare Function ClientToScreen Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long
Private Type POINTAPI
x As Long
y As Long
End Type
Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim pt As POINTAPI
pt.x = x / Screen.TwipsPerPixelX
pt.y = y / Screen.TwipsPerPixelY
Caption = pt.x
ClientToScreen Command1.hwnd, pt
SetCursorPos pt.x - y / Screen.TwipsPerPixelX, pt.y - y / Screen.TwipsPerPixelY
End Sub
Private Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
Private Declare Function ClientToScreen Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long
Private Type POINTAPI
x As Long
y As Long
End Type
Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim pt As POINTAPI
pt.x = x / Screen.TwipsPerPixelX
pt.y = y / Screen.TwipsPerPixelY
Caption = pt.x
ClientToScreen Command1.hwnd, pt
SetCursorPos pt.x - y / Screen.TwipsPerPixelX, pt.y - y / Screen.TwipsPerPixelY
End Sub
doen't work
what would?
Just change it a little. Add a module and declare the API's and the Type Public there:
In a basic module:
And in the form's code window:Code:Public Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
Public Declare Function ClientToScreen Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long
Public Type POINTAPI
x As Long
y As Long
End Type
Code:Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim pt As POINTAPI
pt.x = x / Screen.TwipsPerPixelX
pt.y = y / Screen.TwipsPerPixelY
Caption = pt.x
ClientToScreen Command1.hwnd, pt
SetCursorPos pt.x - y / Screen.TwipsPerPixelX, pt.y - y / Screen.TwipsPerPixelY
End Sub
What did you change? It worked on mine. also remove that caption line, it's not nessesary