With some mouse
utilities you can set that the
mousepointer automaticlly moves to the
control which has the focus, this tip
shows how you can do the same in VB.
Create a .exe project with a module and
add the following code to it:
Declare Function SetCursorPos Lib
"user32" (ByVal x _
As Long, ByVal y As Long) As Long
On
form1 put a couple of controls
(textbox1,commandbutton1,combo1,list1
etc.)
First add the following code to form1
Private Sub focus()
If Me.BorderStyle = 0 Then
x& = Me.ActiveControl.Left \
Screen.TwipsPerPixelX _
+ ((Me.ActiveControl.Width / 2) /
Screen.TwipsPerPixelX) _
+ (Me.Left / Screen.TwipsPerPixelX)
y& = Me.ActiveControl.Top \
Screen.TwipsPerPixelY _
+ ((Me.ActiveControl.Height / 2) /
Screen.TwipsPerPixelY) _
+ (Me.Top / Screen.TwipsPerPixelY)
Else
x& = Me.ActiveControl.Left \
Screen.TwipsPerPixelX _
+ ((Me.ActiveControl.Width / 2 + 60) / _
Screen.TwipsPerPixelX) + (Me.Left / _
Screen.TwipsPerPixelX)
' "+ 60" is for the
border"
y& = Me.ActiveControl.Top \
Screen.TwipsPerPixelY _
+ ((Me.ActiveControl.Height / 2 + 360) /
_
Screen.TwipsPerPixelY) + (Me.Top / _
Screen.TwipsPerPixelY)
' "+ 360 " is for the border
and the tittle bar"
End If
a& = SetCursorPos(x&, y&)
End Sub
Then
put " Call focus " in the
gotfocus event of every control.
Execute the app. (F5) and Tab through the
controls, you`ll see that the
mousepointer moves it`s position to the
control with focus
|