Declare Function SetCursorPos Lib "user32" (ByVal x _
As Long, ByVal y As Long) As Long '- disporre sul form1 un po' di controlli ' (textbox1,commandbutton1,combo1,list1 etc.) '- aggiungere al form1 il seguente codice: 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 porre l'istruzione " Call focus " nell'evento gotfocus di ogni controllo. |