Results 1 to 11 of 11

Thread: RichTextbox Woahs

Threaded View

  1. #1

    Thread Starter
    PowerPoster Arc's Avatar
    Join Date
    Sep 2000
    Location
    Under my rock
    Posts
    2,336

    RichTextbox Woahs

    OK i am using an RTB and i have the Word wrap turned off with a bit of API. So it acts like a listbox.

    Here is the code i use to do that.

    VB Code:
    1. Public Declare Function SendMessageLong Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    2. Public Const WM_USER = &H400
    3. Public Const EM_SETTARGETDEVICE = (WM_USER + 72)
    4.  
    5. Private Sub RT_Change()
    6. SendMessageLong RT.hWnd, EM_SETTARGETDEVICE, 0, 1
    7. End Sub
    8.  
    9. If RT.TExt <> "" Then
    10. RT.Text = RT.Text & vbCrLf & sItem
    11. Else
    12. RT.Text = sItem
    13. End If


    I also have it so that when i click on the RIchtextbox it selects the text i click on.

    VB Code:
    1. Private Sub RT_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
    2. SendKeys "{HOME}"
    3. End Sub
    4.  
    5. Private Sub RT_Click()
    6. On Error Resume Next
    7. Dim a As String
    8. a = RT.GetLineFromChar(RT.SelStart)
    9. RT.SelLength = Len(a)
    10. End Sub

    my ONLY problem with this is when i click on an item that is longer than the RTB is wide, it scrolls over to the end of the selected text.

    I dont want it to do that! i want it to select the text and stay where it is. So it acts like a listbox.

    I either need it to select the text and NOT have the cursor move or once the cursor Moves i need it to move back to the beggining of the text. OR IF i can't move the cursor without unselecting the text i need to scroll back to the left side of the RTB somehow and leave the text selected.
    Code:
    I.e.
                if the RTB Starts here|and ends here     |
                                      |                  |
                                      |DFGDFGDFGDFGDFGDDFgdfgdfgdfgdfg
                                      |                  |
                                      |                  |
    well then it scrolls to where the lower case letters are. I need it to scroll back to the first UCase "D".




    THere must be some way to do this. Either with API or regular RTB methods. PLEASE HELP!

    Let me say that this code is taken from a big project so it doesnt work exactly as i have explained it. I left alot out for simplicity sake.


    Thanks alot
    Last edited by Arc; Dec 12th, 2001 at 04:11 PM.
    -We have enough youth. How about a fountain of "Smart"?
    -If you can read this, thank a teacher....and since it's in English, thank a soldier.


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