Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
568 views
in Technique[技术] by (71.8m points)

.net - How to detect if a scrollbar is or is not at the end of a richtextbox (vb.net)

my question is as is:How to detect if a scrollbar is at or not at the end of a richtextbox?

edit: when I say at the end I mean completely scrolled to the bottom, not anywhere else.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Check out the GetScrollRange and GetScrollPos API...

Private Const SBS_HORZ = 0
Private Const SBS_VERT = 1

<DllImport("user32.dll")> _
Public Function GetScrollRange(ByVal hWnd As IntPtr, ByVal nBar As Integer, _
                               ByRef lpMinPos As Integer, _
                               ByRef lpMaxPos As Integer) As Boolean
End Function

<DllImport("user32.dll")> _
Public Function GetScrollPos(ByVal hWnd As Integer, _
                             ByVal nBar As Integer) As Integer
End Function

// ...

Dim scrollMin as Integer = 0
Dim scrollMax as Integer = 0

If(GetScrollRange(rtb.Handle, SBS_VERT, scrollMin, scrollMax) Then
   Dim pos as Integer = GetScrollPos(rtb.Handle, SBS_VERT)

   // Detect if they're at the bottom
EndIf

Notes:

To determine if the scrollbar is visible, call GetWindowLong and check for WS_VSCROLL

To determine the max value the slider can get to, call GetScrollInfo; I think the maximum value is

scrollMax - largeChange + 1

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...