CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2001
    Location
    India
    Posts
    173

    Finding where the Cursor is ...

    Hello Gurus,

    I have a simple basic problem.

    Inside a textbox, there will be some text, and when the cursor is moved within the textbox, when it is in the begining or in the end, I want to move the cursor to another text box

    We need to know where exactly the cursor is within a textbox either in the begining or in end

    Any help is greatly apprecited.

    Thankx in advance.

    Regards,
    Shivakumar G.M.

  2. #2
    Join Date
    Sep 2001
    Location
    Québec, Canada
    Posts
    1,923

    cursor

    Use GetCursorPos and SetCursorPos APIs

    for APIs infos,
    http://www.allapi.net
    http://www.vbapi.com

    And use the TextBox mouse_move event

    JeffB
    CodeGuru VB FAQ Visual Basic Frequently Asked Questions
    VB Code color Tool to color your VB code on CodeGuru
    Before you post Importants informations to know before posting

  3. #3
    Join Date
    Aug 2001
    Location
    India
    Posts
    173
    tried in site allapi.net

    but there are

    No functions found that begin with the letter G

  4. #4
    Join Date
    Feb 2002
    Location
    Makati City, Philippines
    Posts
    1,054
    Try this and just make adjustments.
    Code:
    Private Sub Text1_Change()
        If Text1.SelStart = Text1.MaxLength Then
            SendKeys "{Tab}"
        End If
    End Sub
    
    
    Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer)
        If KeyCode = vbKeyLeft Then
            If Text1.SelStart = 0 Then
                SendKeys "+{Tab}"
            End If
        ElseIf KeyCode = vbKeyRight Then
            If Text1.SelStart = Text1.MaxLength Or Text1.SelStart = Len(Text1.Text) Then
                SendKeys "{Tab}"
            End If
        End If
    End Sub
    Marketing our skills - please participate in the survey and share your insights
    -

  5. #5
    Join Date
    Sep 2001
    Location
    Québec, Canada
    Posts
    1,923

    oops

    Ooops, sorry, I thought you were talking of MouseCursor, what you need is the SelStart of a TextBox, aio is right about sending Tab key, but you can also use textbox2.SetFocus, and then set the SelStart of that textbox

    JeffB
    CodeGuru VB FAQ Visual Basic Frequently Asked Questions
    VB Code color Tool to color your VB code on CodeGuru
    Before you post Importants informations to know before posting

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured