|
-
Dec 12th, 2001, 04:00 PM
#1
Thread Starter
PowerPoster
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:
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.
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.

-
Dec 12th, 2001, 04:07 PM
#2
Fanatic Member
after selecting the text just set the cursor postion or sel start back to the start of the line
that will stop it scrolling
-
Dec 12th, 2001, 04:09 PM
#3
Thread Starter
PowerPoster
Yah it stops it from scroling but it also DESELECTS THE TEXT! Which is what i DONT want to happen
-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.

-
Dec 12th, 2001, 04:11 PM
#4
Fanatic Member
you could use send message api and the setcursorlocation
I cant remember the link but if you do a search for cursorpostion and textbox on msdn you should find it
-
Dec 12th, 2001, 04:32 PM
#5
Thread Starter
PowerPoster
Hmm sounds like a possibility. IF anyone is good at that API stuff feel free to chime in
-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.

-
Dec 12th, 2001, 06:53 PM
#6
Thread Starter
PowerPoster
-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.

-
Dec 12th, 2001, 08:36 PM
#7
You could simply send the WM_HSCROLL message to scroll to the start.
Simply pass SB_PAGELEFT in the wParam of SendMessage.
Since you pass the message to a RTB the lParam should be 0.
Is this about the same thing you asked before about moving the caret?
In that case this explenation about what you're trying to achieve is much easier to understand 
Best regards
-
Dec 12th, 2001, 09:06 PM
#8
Thread Starter
PowerPoster
Cool i'll give it a shot!
What are the Constants for WM_HSCROLL & SB_PAGELEFT?
The APi i can find the constans i have no clue where to find.
-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.

-
Dec 12th, 2001, 11:06 PM
#9
Thread Starter
PowerPoster
I tried guessing at the values of the constants to no avail. Perhaps you can fill me in Joacim?
Thanks alot!
-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.

-
Dec 13th, 2001, 01:47 AM
#10
Sure!
VB Code:
Private Const WM_HSCROLL = &H114
Private Const SB_PAGELEFT = 2
They do both exist in the API Viewer.
Click the combo box named "API Type" and pick Constants to see all constants (well all that are included with the API Viewer anyway).
There is also a better API Viewer application available at: www.allapi.net
Best regards
Last edited by Joacim Andersson; Dec 13th, 2001 at 01:51 AM.
-
Dec 13th, 2001, 07:46 PM
#11
Thread Starter
PowerPoster
Joacim. I am using the API you suggested. however it doesnt do anything. No errors or anything, it's just like the code isnt event there.
I am using it like this.
Call SendMessage(RT.hwnd, WM_HSCROLL, SB_PAGELEFT, 0)
Where RT is the name of the RTB. I am using it in the RT_Click event but i have tried it several ways to no avail.
Any ideas?
Thanks.
-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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|