Valhalla Legends Archive

Programming => General Programming => Visual Basic Programming => Topic started by: Lenny on February 07, 2004, 08:48 PM

Title: rtb Issue
Post by: Lenny on February 07, 2004, 08:48 PM
Whenever I minimize my richtextbox and a change occurs while it is minimized (such as an rtbAdd), all the text is pushed up for some reason when I restore the window.

Title: Re:rtb Issue
Post by: Lobo on February 07, 2004, 09:30 PM
rtbChat.Find rtbChat.Text, 0, Len(rtbChat.Text)

Put that in your form resize sub.
Title: Re:rtb Issue
Post by: Lenny on February 07, 2004, 10:53 PM
I had not realized there was a Find function for the rtb, but after experimenting with the code you gave me and some other ideas of my own, the richtextbox still pushes all the text beyond the visible area when I restore...

I suppose this just a small problem, and in some cases a good feature.
Title: Re:rtb Issue
Post by: Lobo on February 07, 2004, 10:55 PM
Did you place the code at the end of your resize code?
Title: Re:rtb Issue
Post by: Lenny on February 07, 2004, 10:57 PM
Quote from: Lobo.iD on February 07, 2004, 10:55 PM
Did you place the code at the end of your resize code?

Yes I did, right above the End Sub
Title: Re:rtb Issue
Post by: Lobo on February 07, 2004, 11:14 PM
hmm, wierd sorry my code didn't help, it's what I always used. Good luck on finding a solution.
Title: Re:rtb Issue
Post by: Lenny on February 07, 2004, 11:28 PM
Did you have the same problem?
Title: Re:rtb Issue
Post by: Grok on February 07, 2004, 11:42 PM
Show some code.
Title: Re:rtb Issue
Post by: Lobo on February 07, 2004, 11:56 PM
No I don't have the same problem.  Do what grok said show us some code,  we will be able to better aid your problem.
Title: Re:rtb Issue
Post by: Lenny on February 08, 2004, 12:24 AM

'Vertical
rtbChat.Height = 0.63 * Me.ScaleHeight

'Horizontal
rtbChat.Width = Me.ScaleWidth - 2955


This is the form resize for my rtb...
the .63 is the scale relative to the actual form (.63 : 1)
Title: Re:rtb Issue
Post by: Grok on February 08, 2004, 12:41 AM
Oh boy!  Two whole lines.  Someone with ESP will have to help you.
Title: Re:rtb Issue
Post by: Newby on February 08, 2004, 12:51 AM
At the end of your function.

Put something like

rtb.SetStart = Len(rtb.Text)

That should help =|
Title: Re:rtb Issue
Post by: Lenny on February 08, 2004, 01:56 AM

Public Sub rtbAdd(ParamArray Elements() As Variant)
   rtbTimeStamp "[" & Format(Time, "hh:mm:ss") & "] ", vbWhite
   Dim i As Integer
       For i = LBound(Elements) To UBound(Elements) Step 2
           With rtbChat
               .SelStart = Len(.text)
               .SelLength = 0
               .SelColor = Elements(i + 1)
               .SelText = Elements(i)
               .SelStart = Len(.text)
           End With
       Next i
End Sub
Public Sub rtbTimeStamp(ByVal txtOne As String, ByVal clrOne As Long)
   With rtbChat
       .SelStart = Len(.text)
       .SelLength = 0
       .SelColor = clrOne
       .SelText = txtOne
   End With
End Sub

My rtbAdd function...
Title: Re:rtb Issue
Post by: Lobo on February 08, 2004, 09:45 AM
The rtbAdd code should not result in the problem your haveing, post your resize code, also set a breakpoint on the code I gave you to put in, see if it is ever executed.
Title: Re:rtb Issue
Post by: Lenny on February 09, 2004, 08:55 PM
The resize code I posted earlier is the only code I have for my rtb right now...


rtbChat.Height = 0.63 * Me.ScaleHeight


When I disable this, the rtb works normally as it should, perhaps you can't use this kind of syntax for setting height...Its unfortunate, I thought I had found an easier way to deal with resizing controls through the use of ratios
Title: Re:rtb Issue
Post by: Lobo on February 09, 2004, 09:34 PM
I don't know if this will help any but...


Const Padding As Integer = 15 * 15
rtbChat.Height = Me.ScaleHeight - Padding


It's subtracting 15 pixels(I Believe).

Hope that helps.
Title: Re:rtb Issue
Post by: Lenny on February 11, 2004, 02:08 PM
Actually I solved my problem by Exiting Sub whenever it was a minimize, perhaps the window became so small on a minimize that the text was being shifted to the top...
Title: Re:rtb Issue
Post by: Lobo on February 11, 2004, 05:24 PM
Glad you got it figured out. Sorry if I was not much of help.