Postup:
Založte nový
projekt. Připojte modul, a v něm deklarujte:
Declare Function
SetCursorPos Lib "user32" (ByVal x _ As Long, ByVal y As Long) As
Long
Do modulu přidejte následující
proceduru:
Public Sub Afocus()
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)
y& = Me.ActiveControl.Top \ Screen.TwipsPerPixelY
_
+ ((Me.ActiveControl.Height / 2 + 360) / _
Screen.TwipsPerPixelY) + (Me.Top / _
Screen.TwipsPerPixelY)
End If
a& = SetCursorPos(x&, y&)
End Sub
Na formulář
natáhněte pár prvků - tlačítka, textboxy atd. a jim na událost
GotFocus dejte volání procedury AFocus(). Spusťte projekt a zkoušejte se
pohybovat mezi prvky tabulátorem. Ukazatel myši se bude automaticky přesouvat.
|