freezing richtextbox from scrolling while outputting text
Hi all ... just wonder if there is any codes out there that can freeze the richtextbox from scrolling when outputting a long string of text.
My problem is when outputting a large amount of lines into a richtextbox, it tends to scroll along the last line of input. I want it to be fixed at the top of the richtextbox when outputting. Sometimes .. it remains at the top ... but sometimes .. it follows the last line ... this is weird ... probably due to the system graphic memory ...
Appreciate if anyone can tell me how to freeze the richtextbox when outputting.
Thanks !
Chris
Re: freezing richtextbox from scrolling while outputting text
Any clues from any gurus out there ???
Re: freezing richtextbox from scrolling while outputting text
can u simply disable the rtb while it is outputting?
rtb.enabled = false
:confused:
Re: freezing richtextbox from scrolling while outputting text
Nope .. it is not working ... the rtb still scrolls ...
:confused: :confused: :eek:
Re: freezing richtextbox from scrolling while outputting text
how about making it not visible?
Re: freezing richtextbox from scrolling while outputting text
What code you are using to output text to the RTB?
Re: freezing richtextbox from scrolling while outputting text
I'd be interested in that, also.
Re: freezing richtextbox from scrolling while outputting text
Have you tried RTB.Selstart = 0 ?
EDIT : Sorry just reread and saw that it is DURING the load that you have the issue.
Re: freezing richtextbox from scrolling while outputting text
Glad that someone also share the same interest in solving this problems with me ....
Anyway ... cannot use rtb.selstart = 0 .... reason .... I am outputting text to the rtb using rtb.seltext = "blah .. blah blah ..."
So ... when the list of text starts to hit the bottom of the rtb height ... it will automatically ... have a vertical scroll bar ... and starts scrolling down while I am still outputting text to it.
Talk about it ... I think I can disable the vertical scrollbar when outputting and then turn it back on when I'm done outputting. I am going to try it now.
Come back later to post the result.
Cheers.
Re: freezing richtextbox from scrolling while outputting text
I am not sue if this helps but the attached code fills a Rich textbox in the blinkof an eye if that's what you are trying to do. I still am not sure what you mean by outputing you see. Outputting to the RTB or Outputting from the RTB. If it is TO the RTB then the highlighted line is what you need.
Code:
str = dLog & "\temp1log.txt"
Set F1 = fso.GetFile(str)
Set ts1 = F1.OpenAsTextStream(ForReading)
If F1.Size < 10 Then
RichTextBox1.Text = "Sorry but this file is Empty"
GoTo Done
End If
RichTextBox1.TextRTF = ts1.ReadAll '<<<<<<<<
HTH
.
Re: freezing richtextbox from scrolling while outputting text
Argghhh ..... rtb.scrollbar cannot be changed during runtime .... becos it is a read-only field ..... so sad ..... this method cannot be feasible ....
thanks dave for your tips .... however, I am not outputting from a file. I am outputting from recordset ... from a database .... hence ... I read record by record ... and format them ... accordingly ... some bold .. some italic .. using selitalic ... selbold .... etc ... hence, the output is slow ... line by line outputting. I want it to appear in the rtb as it is outputting, but I dun want it to scroll when it hits the bottom of the rtb. That is my main problem.
Anyone has any API .. or something to disable the scrolling of rtb ?
Re: freezing richtextbox from scrolling while outputting text
I'd like to see some examples of writing to a RTB. I haven't seen many, and can't believe that nobody has posted anything!
Re: freezing richtextbox from scrolling while outputting text
ok dglienna .. since you wanna see my code ... here is a small fraction of it ... hope it helps you in outputting to rtb
Code:
If ListNum = 7 Then
If List7.ListCount <> 0 Then
If List7.ListCount > 1 Then
RichTextBox1.SelBold = True
RichTextBox1.SelColor = vbBlack
RichTextBox1.SelIndent = 0
RichTextBox1.SelFontSize = 10
RichTextBox1.SelText = vbCrLf & "Antonym Translations" & vbCrLf
RichTextBox1.SelFontSize = 9
Else
RichTextBox1.SelBold = True
RichTextBox1.SelColor = vbBlack
RichTextBox1.SelIndent = 0
RichTextBox1.SelFontSize = 10
RichTextBox1.SelText = vbCrLf & "Antonym Translation" & vbCrLf
RichTextBox1.SelFontSize = 9
End If
For I = 0 To List7.ListCount - 1
MyResult = List7.List(I)
MyResult = Replace(MyResult, ", ,", "")
Debug.Print MyResult
RichTextBox1.SelBold = False
RichTextBox1.SelColor = vbBlack
RichTextBox1.SelFontSize = 9
RichTextBox1.SelIndent = 250
If I > 8 Then
RichTextBox1.SelHangingIndent = 270
Else
RichTextBox1.SelHangingIndent = 180
End If
RichTextBox1.SelText = I + 1 & ". "
RichTextBox1.SelText = Mid(MyResult, 1, InStr(MyResult, "="))
MyResult = Mid(MyResult, InStr(MyResult, "=") + 1)
MyReDo3:
If InStr(MyResult, "(") Then
If I > 8 Then
RichTextBox1.SelHangingIndent = 270
Else
RichTextBox1.SelHangingIndent = 180
End If
RichTextBox1.SelBold = True
RichTextBox1.SelText = Mid(MyResult, 1, InStr(MyResult, "(") - 1)
RichTextBox1.SelBold = False
RichTextBox1.SelText = "("
MyResult = Mid(MyResult, InStr(MyResult, "(Also ") + 6)
RichTextBox1.SelItalic = True
RichTextBox1.SelText = "also "
RichTextBox1.SelItalic = False
RichTextBox1.SelText = Mid(MyResult, 1, InStr(MyResult, ")"))
MyResult = Mid(MyResult, InStr(MyResult, ")") + 1)
If MyResult <> "" Then
GoTo MyReDo3
Else
RichTextBox1.SelText = vbCrLf
End If
Else
RichTextBox1.SelBold = True
RichTextBox1.SelText = MyResult
RichTextBox1.SelBold = False
RichTextBox1.SelText = vbCrLf
End If
Next I
End If
End If
Re: freezing richtextbox from scrolling while outputting text
Thanks. I will take a look at it to try to figure out how to use it. I have a WYSIWYG RTB that is the same as my printer, but haven't figured out how to center things. I have tried using the SPACE() function, but am having trouble. I see that I have to use twips for positioning, but am still unclear as to how. Is there a way to print at a tab location? I wonder if I can set tabs on the rtb? I have something that will do it for a Listbox.
Re: freezing richtextbox from scrolling while outputting text
Try the LockWindowUpdate API. Just pass the rtb's handle to lock it and
then pass 0 to unlock it.
Code:
Private Declare Function LockWindowUpdate Lib "user32.dll" (ByVal hwndLock As Long) As Long
Re: freezing richtextbox from scrolling while outputting text
Thanks RobDog888 ... might be the one I am looking for.
Cheers :bigyello:
Re: freezing richtextbox from scrolling while outputting text
No prob. :thumb: hope it works out for you.
Re: freezing richtextbox from scrolling while outputting text
I'm having luck using .Find to find [1], and then replacing it with my variable, which I already have in a textbox on a form. It is already formatted!
The only problem is that if I right-align it, then the lines on the table mess up. I can pad it with spaces, though. I probably have [50] variables.
Makes for a *LOT* of code, but it works.
You might want to use .Find to get to the top line of your RTF, after it writes the DB. It's not elegant, but it will work.
I have a bmp in my RTF, and now I need a way to replace the contents with the one from the program. Any idea how to do it? It wouldn't be hard to save it as a file, if there is a way to read it into the right area, but I'd like to be able to paste it there.