• Welcome to Valhalla Legends Archive.
 

Rich Text Box MnuLockChat

Started by ______, April 11, 2003, 03:24 PM

Previous topic - Next topic

______

How would i lock chat on a pop up menu from a rich text box to read previous messages?

Lobo

Quote from: ______ on April 11, 2003, 03:24 PM
How would i lock chat on a pop up menu from a rich text box to read previous messages?
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.
Look it's a signature.

Mesiah / haiseM

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.
]HighBrow Innovations
Coming soon...

AIM Online Status: 

Lobo

Look it's a signature.

Banana fanna fo fanna

LockWindowUpdate would work, except you can't scroll.

But it's the easiest way!

JoeCool

dont u right click on the rich text box and go to properties? :D

dxoigmn

Quote from: ______ on April 11, 2003, 03:24 PM
How would i lock chat on a pop up menu from a rich text box to read previous messages?

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.

Camel

Quote from: kamakazie on July 08, 2003, 10:23 PMI 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.
Not only mIRC does that; it's AFAIK the standard and accepted solution.

Camel

Took about 10 minutes to figgure this out with google's help. :)
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

       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

CupHead

#9
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.)

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?
"Now, gentlemen, let us do something today which the world make talk of hereafter."
- Admiral Lord Collingwood

Noodlez

Yea, zorm, just check if the scrollbar is not at the bottom. If it isn't, prevent your AddText function from scrolling.

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.

dxoigmn

#13
Or you can do some fun subclassing in VB to stop it from scrolling!   :-\

CupHead

I'm curious as to what you mean by "the selection being moved".