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:
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 Public Const WM_USER = &H400 Public Const EM_SETTARGETDEVICE = (WM_USER + 72) Private Sub RT_Change() SendMessageLong RT.hWnd, EM_SETTARGETDEVICE, 0, 1 End Sub If RT.TExt <> "" Then RT.Text = RT.Text & vbCrLf & sItem Else RT.Text = sItem End If
I also have it so that when i click on the RIchtextbox it selects the text i click on.
VB Code:
Private Sub RT_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single) SendKeys "{HOME}" End Sub Private Sub RT_Click() On Error Resume Next Dim a As String a = RT.GetLineFromChar(RT.SelStart) RT.SelLength = Len(a) 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.
well then it scrolls to where the lower case letters are. I need it to scroll back to the first UCase "D".Code:I.e. if the RTB Starts here|and ends here | | | |DFGDFGDFGDFGDFGDDFgdfgdfgdfgdfg | | | |
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![]()





Reply With Quote