PDA

View Full Version : Cursor auto position in textbox


ceal21c
05-25-06, 11:49
Hey Guys,

How do I get my cusor to automaticaly go to a specific textbox when I load a form?

ceal21c
05-25-06, 12:02
This worked for me:

Either set that textboxe's tabindex property to zero, or in the Form_Activate event code sub add TextBox1.SetFocus :)

x411man
05-25-06, 15:38
If you want to mouse to "jump" to a label or text box etc. the here is the code to move the mouse

Option Explicit

Private Type POINTAPI
x As Long
y As Long
End Type

Private Declare Function ClientToScreen Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long
Private Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long

Sub MoveMouse(x As Single, y As Single)
Dim pt As POINTAPI

pt.x = x
pt.y = y
ClientToScreen hwnd, pt
SetCursorPos pt.x, pt.y
End Sub

Private Sub Form_Load()
MoveMouse Target.Left + Target.Width / 2, _
Target.Top + Target.Height / 2
End Sub


My code moves the mouse to the middle of a circle shape called "Target".