Cursor auto position in textbox

Discussion in 'Software' started by ceal21c, May 25, 2006.

  1. ceal21c

    ceal21c Private E-2

    Hey Guys,

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

    ceal21c Private E-2

    This worked for me:

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

    x411man Private E-2

    If you want to mouse to "jump" to a label or text box etc. the here is the code to move the mouse

    Code:
    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".
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds