Scrollable Window question

5 views
Skip to first unread message

XavRam

unread,
Sep 14, 2008, 12:03:16 AM9/14/08
to EEGUI
So i set up this class to handle a multiline text box with the ability
to scroll it, very similar to the one set up in the demo. I'm using
it for player interaction (speech). Here's the current class.

Imports EEGUI
Imports System.IO
Imports MTV3D65

Public Class MyScrollingWindow
Inherits guiWindowEnhanced

Public WithEvents MLText As New MyMultiLineLabel

Public Overridable Sub Initialize()
With Me
.Name = ""
.ScrollbarAutoVisibility = True
.ScrollBarSetting = ScrollBars.Vertical
.AllowResize = False
.AlwaysOnTop = True
End With

AddChild(MLText)
InitVScrollbar()
End Sub

Private Sub InitVScrollbar()
With VScrollBar
With .TopButton.Background
With .Base.Texture
.Enabled = True
.Tex = "UpArrow"
End With
End With
With .BottomButton.Background
With .Base.Texture
.Enabled = True
.Tex = "DownArrow"
End With
End With
.ScrollAmount = 5
End With
End Sub

End Class

I have a couple of things I can't quite figure out and was hoping
someone could clarify.

1. When someone says something, it adds text to the end of the MLText
component. But if this is already at the bottom, you can't see the
text unless you scroll down one one click. So when someone adds text
to the MLText control, I would like it to automatically fire off the
VScrollBar.BottomButton.ClickEventHandler...but i can't seem to figure
out how to do this.

2. You can freely scroll the control, even past the point where any
text exists. Is it possible to limit how far down the scroller can
go? Something like the "Max" property of a traditional scroll bar? I
was thinking I could just increase this each time text is added, thus
keeping track of a "limit" for the scroll bar...but I don't know if
that's possible. I tried messing with the InnerBounds property of the
VScrollBar but it didn't seem to work.

Oh, and not related to this class but somewhat related...when someone
presses the "Return" key, I want to set the focus on a EEGUI.TextBox
control. Thought I could just use "txtText.SetFocus = True" but it
doesn't seem to work. Suggestions?

Thanks!

Jared Mark

unread,
Sep 14, 2008, 10:45:42 PM9/14/08
to ee...@googlegroups.com
1) I am removing the guiWindowEnhanced from EEGUI. It should have never
been in there in the first place. It is, quite simply, "too complex and
specialized" of a control to be a part of the library.
2) I posted a few messages about this sort of thing a few weeks back,
specifically how I did my own chat box.

I would not use a MultiLineLabel as the container for the chat. I would use
a listbox, with each of the chat items being its own child of the listbox.
Sort by TagString or TagID, and set the sorted Tag to a timestamp.

Like so:

Public Class ChatMessageArea
Inherits StdListBox

Public Overrides Sub Initialize()
MyBase.Initialize()
SortAscending = True
Me.SortingMethod = SortingMethods.ByTagID
AllowFocus = True
End Sub

Public Sub AddMessage(ByVal M As String)
Dim lbl As New ChatRoomMessage
lbl.Initialize(M)
lbl.TagID = Now.Ticks
lbl.Width = Width
AddChild(lbl)
VScrollBar.Slider.Top = VScrollBar.BottomButton.Top -
VScrollBar.Slider.Height
End Sub

Private Sub IWasResized() Handles MyBase.Resized
For Each C As ChatRoomMessage In Children
C.Width = Width
Next
VScrollBar.Slider.Top = VScrollBar.BottomButton.Top -
VScrollBar.Slider.Height
End Sub

End Class

Public Class ChatRoomMessage
Inherits guiMultilineLabel

Public Overridable Sub Initialize(ByVal Msg As String)
Text = Msg
Hide()
Me.ForeShadowOffset = 0
With Me
With .Foreground.Base.Color
.Enabled = True
.RGBAInt = CONST_TV_COLORKEY.TV_COLORKEY_WHITE
End With
With .Border.Base.Color
.Disable()
.TVColor = New TV_COLOR(0.75, 0.75, 0.75, 0.9)
End With
End With
End Sub

End Class

As you can see, when I add a message, I create a new ChatRoomMessage object,
set the TagID to Now.Ticks, and the whole listbox is sorted by TagID.

When a message is added, the VScrollBar.Slider.Top is set to the top of the
bottom button minus the slider's height (basically "scrolled all the way
down").

Easy! :)

AddChild(MLText)
InitVScrollbar()
End Sub

End Class

Thanks!

No virus found in this incoming message.
Checked by AVG - http://www.avg.com
Version: 8.0.169 / Virus Database: 270.6.21/1671 - Release Date: 9/14/2008
7:16 AM

XavRam

unread,
Sep 15, 2008, 11:49:56 AM9/15/08
to EEGUI
Hmmm, okay, trying to implement this but one thing I'm not getting...

Public Class ChatMessageArea
> Inherits StdListBox
>
> Public Overrides Sub Initialize()
> MyBase.Initialize()


What is "StdListBox"? Its not the guiListBox, is it? Because the
guiListBox doesn't have an Initialize method to override....
> Checked by AVG -http://www.avg.com
> Version: 8.0.169 / Virus Database: 270.6.21/1671 - Release Date: 9/14/2008
> 7:16 AM- Hide quoted text -
>
> - Show quoted text -

XavRam

unread,
Sep 15, 2008, 12:28:08 PM9/15/08
to EEGUI
Never mind, did something stupid!!! Seems to be working pretty well,
have to tweak some stuff but this looks pretty darn good
Jared...thanks!
> > - Show quoted text -- Hide quoted text -

Jared Mark

unread,
Sep 15, 2008, 1:21:23 PM9/15/08
to ee...@googlegroups.com
Yeah, stdlistbox is just another layer of inheritance that I use... not much
there, though... just some defaults for my listbox settings.
Checked by AVG - http://www.avg.com
Version: 8.0.169 / Virus Database: 270.6.21/1671 - Release Date: 9/15/2008
9:21 AM

XavRam

unread,
Sep 15, 2008, 3:14:55 PM9/15/08
to EEGUI
One other follow up this...I wanted to make teh height of each
"ChatRoomMessage" smaller, there seems to be too much white space
between each line. However, since those classes need to autosize (to
adapt for pieces of text that take up multiple lines), I'm not sure
how to accomplish that. Any ideas?
> Version: 8.0.169 / Virus Database: 270.6.21/1671 - Release Date: 9/15/2008
> 9:21 AM- Hide quoted text -

XavRam

unread,
Sep 15, 2008, 4:11:22 PM9/15/08
to EEGUI
And another thing...In the ChatMessageArea that inherits from the
listbox, I tried to call RemoveAllChildren to clear out all the
messages...but when I do this, I get an error message ("Collection was
modified; enumeration operation may not execute."). Am I using this
wrong or is this a bug? If it's not a bug, then how do I go about
clearing out all the messages (the multiline controls) from the list
box?

Jared Mark

unread,
Sep 16, 2008, 1:50:47 AM9/16/08
to ee...@googlegroups.com
Hmmm, probably a bug...

I think I know how to fix it. Until then, you could make Children = New
List(of guiControlBase)
Checked by AVG - http://www.avg.com
Version: 8.0.169 / Virus Database: 270.6.21/1672 - Release Date: 9/15/2008
9:21 AM

XavRam

unread,
Sep 16, 2008, 11:00:13 AM9/16/08
to EEGUI
That doesn't appear to be valid. I'm in VB.Net and "List" isn't valid
(Type "List" is not defined).

Children = New List(Of MyListBoxItem)
> Version: 8.0.169 / Virus Database: 270.6.21/1672 - Release Date: 9/15/2008
> 9:21 AM- Hide quoted text -

XavRam

unread,
Sep 16, 2008, 11:16:56 AM9/16/08
to EEGUI
Got this one figured out, ignore it...had the autosize and height
parameters in the wrong order to achieve this.

On Sep 15, 1:14 pm, XavRam <dream...@pcisys.net> wrote:

XavRam

unread,
Sep 16, 2008, 4:23:41 PM9/16/08
to EEGUI
For x = scrollerResources.Children.Count - 1 To 0 Step -1
scrollerResources.Children.RemoveAt(x)
Next

That seems to work fine to remove all the Children from a list but it
would be nice if the RemoveAllChildren method actually worked.

Jared Mark

unread,
Sep 17, 2008, 10:54:52 AM9/17/08
to ee...@googlegroups.com
It's a collection type that came out in .NET 2.0
Checked by AVG - http://www.avg.com
Version: 8.0.169 / Virus Database: 270.6.21/1672 - Release Date: 9/16/2008
8:15 AM

XavRam

unread,
Sep 17, 2008, 4:12:17 PM9/17/08
to EEGUI
Jared, there seem to be another problem with this. Into the
ChatMessageArea class, I put in this sub...

Public Sub ClearMessages()
Dim x As Integer
For x = Children.Count - 1 To 0 Step -1
Children.RemoveAt(x)
Next
End Sub

...then I went and added some new messages back into the area.
However, they didn't sort based on TagID, they appear in just random
spots. Is there a way to force a re-sorting of the items in the list
box?

Thanks...was so close to thinking this was finished and working and
now this!
> ...
>
> read more »- Hide quoted text -

Jared Mark

unread,
Sep 17, 2008, 6:46:48 PM9/17/08
to ee...@googlegroups.com
Any change in the children of a listbox should trigger a re-sort.

You can force a resort by changing the sorting order or what the list is
sorted by as well.
Checked by AVG - http://www.avg.com
Version: 8.0.169 / Virus Database: 270.6.21/1676 - Release Date: 9/17/2008
9:33 AM

Reply all
Reply to author
Forward
0 new messages