VB6 RichTextBox string processing: Create like VB Code editor

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • CyberSoftHari
    Recognized Expert Contributor
    • Sep 2007
    • 488

    VB6 RichTextBox string processing: Create like VB Code editor

    Two things i have to do.
    RTB->Rich Text Box
    1. Listbox(Or list view) should follow the cursor position.
    2. Important: Get the word of deleting char in RTB Text. (Not in the end of RTB text).
    Ex: Clicking any word in RTB text and delete any char in that word, here i want the word before deleting any char.
    any help will be a good clue for me. Thank You
  • CyberSoftHari
    Recognized Expert Contributor
    • Sep 2007
    • 488

    #2
    I got the solution for my listBoxControl move over the cursor Position.
    Code:
    Private Declare Function GetCaretPos Lib "user32" (lpPoint As POINTAPI) As Long
    Private Declare Function ClientToScreen Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long
    Private Declare Function ScreenToClient Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long
    Private Type POINTAPI
        X As Long
        Y As Long
    End Type
    
    Private Sub RichTextBox1_KeyPress(KeyAscii As Integer)
        Dim tCaret As POINTAPI
        GetCaretPos tCaret 'get the Caret Position in RichTextbox Coords
        ClientToScreen RichTextBox1.hwnd, tCaret 'get the Coords in Screen Coords
        ScreenToClient hwnd, tCaret 'get the Coords in Form Coords
        List1.Move ScaleX(tCaret.X + 3, vbPixels, vbTwips), ScaleY(tCaret.Y + (RichTextBox1.SelFontSize * 1.3), vbPixels, vbTwips)
    End Sub
    Now looking for my second solution, i.e, Get the word of deleting(Or backSpace) char in Rich Text Box control. Thank you.


    I done my second problem like below
    Code:
        RichTextBox1.UpTo " ", False, False
        RichTextBox1.Span " ", True, True
    Last edited by CyberSoftHari; Oct 24 '13, 06:37 AM. Reason: Done second problem

    Comment

    Working...