How can I get the position of cursor in then text box?

Discussion in 'Questions (Windows Mobile)' started by fishworld2006, Aug 19, 2008.

  1. fishworld2006

    fishworld2006 Member

    I import the lib dzHw,and use function SendMessageToControl.

    'get the position of cursor
    Sub GetCurLine(txtboxname)
    linechar = hdObj.SendMessageToControl(txtboxname, EM_LINEINDEX, -1, 0)
    curline = hdObj.SendMessageToControl(txtboxname, EM_LINEFROMCHAR, linechar, 0)
    linefirstno = hdObj.SendMessageToControl(txtboxname,EM_GETFIRSTVISIBLELINE,0,0)
    Msgbox(curline & "+" & linefirstno,"Tips")
    End Sub

    When debug, an error ocurred."System.OverflowException"
    "linechar = hdObj.SendMessageToControl(txtboxname, EM_LINEINDEX, -1, 0)"
    Error Description: value -1 Uint32 too big or small??

    How can I do? Tks
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    txtboxname.SelectionStart will return the position of the cursor.
     
  3. fishworld2006

    fishworld2006 Member

    Tks erel.
    But when text wordwraped ,value returned from txtboxname.SelectionStart isn't the visible position.
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    txtBoxName.SelectionStart returns the cursor position.
    Are you looking for something else?
     
  5. fishworld2006

    fishworld2006 Member

    value of txtBoxName.SelectionStart is the position from first char of txtBoxName.text, I'd like to get cursor position of visible lines in the textbox .
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice