Skip to content
Permalink
Browse files

[ScrollToBottom] Use a different strategy to scroll to bottom (EM_SCR…

…OLLCARET).
  • Loading branch information...
nmbook committed Oct 31, 2017
1 parent c9d950e commit 397247205e50700f4c8e76abe4e982ded9cb0d42
Showing with 12 additions and 10 deletions.
  1. +2 −2 trunk/frmChat.frm
  2. +10 −8 trunk/modChat.bas
@@ -5677,7 +5677,7 @@ Private Sub cboSend_KeyDown(KeyCode As Integer, Shift As Integer)
Dim n As Long

If (GetVScrollPosition(rtbChat)) Then
SetVScrollBottom rtbChat
ScrollToBottom rtbChat
End If

If (Shift = vbCtrlMask) Then
@@ -5869,7 +5869,7 @@ Private Sub cboSend_KeyDown(KeyCode As Integer, Shift As Integer)
Dim StartOutfilterPos As Long

If (GetVScrollPosition(rtbChat)) Then
SetVScrollBottom rtbChat
ScrollToBottom rtbChat
End If

DoRunCommands = True
@@ -53,8 +53,9 @@ Private Const EM_SETTEXTEX As Long = WM_USER + 97
Private Const EM_GETTEXTEX As Long = WM_USER + 94
Private Const EM_GETTEXTLENGTHEX As Long = WM_USER + 95

Private Const EM_SCROLL As Long = &HB5
Private Const EM_GETTHUMB As Long = &HBE
Private Const EM_SCROLL As Long = &HB5
Private Const EM_SCROLLCARET As Long = &HB7
Private Const EM_GETTHUMB As Long = &HBE

Private Const SB_VERT As Long = 1
Private Const SB_HORZ As Long = 0
@@ -272,7 +273,6 @@ Public Sub DisplayRichText(ByRef rtb As RichTextBox, ByRef saElements() As Varia
With rtb
SetTextSelection rtb, -1, -1
RTBSetSelectedText rtb, vbCrLf
SetTextSelection rtb, -1, -1
End With

If (LogThis) Then
@@ -287,7 +287,7 @@ Public Sub DisplayRichText(ByRef rtb As RichTextBox, ByRef saElements() As Varia

If Not blnCanVScroll And CanVScroll(rtb) Then
' didn't previously have scrollbar but now does
SetVScrollBottom rtb
ScrollToBottom rtb
If (blUnlock) Then
rtb.Visible = True
End If
@@ -842,10 +842,12 @@ Public Function CanVScroll(cnt As Control) As Boolean

End Function

Public Sub SetVScrollBottom(cnt As Control)
Public Sub ScrollToBottom(cnt As Control)

LockWindowUpdate cnt.hWnd
SendMessage cnt.hWnd, EM_SCROLL, SB_BOTTOM, &H0
LockWindowUpdate &H0
SetTextSelection cnt, -1, -1
SendMessageW cnt.hWnd, EM_SCROLLCARET, 0&, 0&
'LockWindowUpdate cnt.hWnd
'SendMessage cnt.hWnd, EM_SCROLL, SB_BOTTOM, &H0
'LockWindowUpdate &H0

End Sub

0 comments on commit 3972472

Please sign in to comment.
You can’t perform that action at this time.