Valhalla Legends Forums Archive | General Programming | Rich Text Box MnuLockChat

AuthorMessageTime
______
How would i lock chat on a pop up menu from a rich text box to read previous messages?
April 11, 2003, 8:24 PM
Lobo.id
[quote author=______ link=board=5;threadid=1016;start=0#msg7586 date=1050092643]
How would i lock chat on a pop up menu from a rich text box to read previous messages?
[/quote]
have your rtb send to a not visible rtb when its locked, and when you unlock it send the text from the not visible rtb to the main one, and delete whats in that rtb.
April 23, 2003, 10:35 PM
MesiaH
or you could place all messages while a locked boolean is enabled, in an array, and when it becomes disabled, add the array items to the rtb, simple concept, more effecient than another rtb.
April 24, 2003, 2:55 AM
Lobo.id
True
April 24, 2003, 4:24 AM
St0rm.iD
LockWindowUpdate would work, except you can't scroll.

But it's the easiest way!
April 25, 2003, 12:46 AM
JoeCool
dont u right click on the rich text box and go to properties? :D
July 9, 2003, 3:20 AM
kamakazie
[quote author=______ link=board=5;threadid=1016;start=0#msg7586 date=1050092643]
How would i lock chat on a pop up menu from a rich text box to read previous messages?
[/quote]

I think the best way to do this is how mIRC does it. Basically, when the scroll bar is not at the bottom, it doesn't scroll at all.
July 9, 2003, 3:23 AM
Camel
[quote author=kamakazie link=board=5;threadid=1016;start=0#msg14228 date=1057720999]I think the best way to do this is how mIRC does it. Basically, when the scroll bar is not at the bottom, it doesn't scroll at all.[/quote]
Not only mIRC does that; it's AFAIK the standard and accepted solution.
July 9, 2003, 6:53 PM
Camel
Took about 10 minutes to figgure this out with google's help. :)
[code]Public Declare Function GetScrollRange Lib "user32" (ByVal hwnd As Long, ByVal nBar As Long, lpMinPos As Long, lpMaxPos As Long) As Long
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

Public Const EM_GETSCROLLPOS = WM_USER + 221
Public Const EM_SETSCROLLPOS = WM_USER + 222

Const SB_HORZ = 0
Const SB_VERT = 1
Const SB_BOTH = 3

Type POINT
x As Long
Y As Long
End Type[/code]
[code] Dim origstart As Long, origlen As Long
origstart = IIf((Len(.Text) - .SelStart) > 10, .SelStart, 0)
origlen = IIf(origstart = 0, 0, .SelLength)

Dim srMin As Long, srMax As Long, myPoint As POINT, ShouldScroll As Boolean
ShouldScroll = False

GetScrollRange frmMain.txtChat.hwnd, SB_VERT, srMin, srMax
SendMessage frmMain.txtChat.hwnd, EM_GETSCROLLPOS, 0, VarPtr(myPoint)
myPoint.Y = myPoint.Y + 1 'i have no idea why this is needed, but it's always 1px too high

If myPoint.Y >= srMax - (frmMain.txtChat.Height / 15) Then ShouldScroll = True

...

.SelStart = IIf(origstart = 0, Len(.Text), origstart)
.SelLength = origlen

If ShouldScroll Then
GetScrollRange frmMain.txtChat.hwnd, SB_VERT, srMin, srMax
myPoint.x = 0
myPoint.Y = srMax - (frmMain.txtChat.Height / 15)
SendMessage frmMain.txtChat.hwnd, EM_SETSCROLLPOS, 0, VarPtr(myPoint)
Else
SendMessage frmMain.txtChat.hwnd, EM_SETSCROLLPOS, 0, VarPtr(myPoint)
End If[/code]
July 9, 2003, 10:26 PM
CupHead
Actually you should use the GetScrollInfo API call. GetScrollRange and GetScrollPos are provided for backwards compatibility. GetScrollInfo provides a handy structure into which you can load all of the information you want. Also, the example you posted is ridiculously complex, which leads me to believe it is not your code (though creation was left ambiguous). A much simpler way would be to use GetScrollPos rather than those ridiculous SendMessage calls. (GetScrollPos' functionality is contained in GetScrollInfo as well.)
July 9, 2003, 10:48 PM
zorm
While looking at that code it appears that the richedit box will still end up scrolling to the bottom and then back up? Has anyone found a way to stop it from scrolling?
July 9, 2003, 11:23 PM
Noodlez
Yea, zorm, just check if the scrollbar is not at the bottom. If it isn't, prevent your AddText function from scrolling.
July 10, 2003, 12:36 AM
Camel
CupHead, yes it is my code. The reason it is complex is because it compensates for the selection being moved: The easiest way in vb to add text to an RTB is to move the selection to the end and modify the .SelColor and .SelText properties. If you cover up that code, it's really not that bad.

Zorm, you would have to not use the aforementioned method to add text to the box. Just set the .visible property of the box to false before and true after modifying the text and it wont flicker. If you're trying to avoid that entirely, you'll probably have to get into writing RTFed text directly to the box.
July 10, 2003, 1:25 AM
kamakazie
Or you can do some fun subclassing in VB to stop it from scrolling! :-\
July 10, 2003, 3:45 AM
CupHead
I'm curious as to what you mean by "the selection being moved".
July 10, 2003, 12:39 PM
Camel
[quote author=CupHead link=board=5;threadid=1016;start=0#msg14424 date=1057840778]
I'm curious as to what you mean by "the selection being moved".
[/quote]

[code] .SelStart = Len(.Text)
.SelColor = ColTimestamp
.SelText = "[" & Date & " " & Time & "] "[/code]
July 10, 2003, 4:25 PM

Search