Results 1 to 4 of 4

Thread: Telling what texts is being edited

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 1999
    Posts
    20

    Post

    How do I tell what Text is being edited?

    ---when I say edited I mean when the insert point is in the text and you can add or delete characters.---

    I want to know what text is being edited so It will change some characters around in the text that the user is editing in.

  2. #2
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177

    Post

    You can get the Current Line of Text st the Caret Postion using the SendMessage API, eg.

    In a Form with 2 Textboxes, Text is Multiline, Text2 is Normal..
    Code:
    Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    Private Const EM_GETLINE = &HC4
    Private Const EM_LINEFROMCHAR = &HC9
    Private Const EM_LINELENGTH = &HC1
    
    Private Sub Command1_Click()
        Dim lLine As Long
        Dim lLen As Long
        Dim sLine As String
        lLine = SendMessage(Text1.hwnd, EM_LINEFROMCHAR, -1, 0&)
        lLen = SendMessage(Text1.hwnd, EM_LINELENGTH, Text1.SelStart, 0&)
        sLine = Space(lLen)
        Call SendMessage(Text1.hwnd, EM_GETLINE, lLine, ByVal sLine)
        Text2 = sLine
    End Sub
    ------------------
    Aaron Young
    Analyst Programmer
    [email protected]
    [email protected]

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Oct 1999
    Posts
    20

    Post

    Thank you Aaron, I have one more question.
    How Do I get the insertion point to the far right side of a text?

  4. #4
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    Text1.Selstart = len(Text1.Text)

    Regards,

    ------------------

    Serge

    Software Developer
    [email protected]
    [email protected]
    ICQ#: 51055819



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