如何检测滚动条是否位于富文本框的末尾(vb.net) [英] How to detect if a scrollbar is or is not at the end of a richtextbox (vb.net)

查看:19
本文介绍了如何检测滚动条是否位于富文本框的末尾(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.

推荐答案

查看 GetScrollRangeGetScrollPos API...

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

注意事项:

要确定滚动条是否可见,请调用 GetWindowLong 并检查 WS_VSCROLL

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

要确定滑块可以达到的最大值,请调用 GetScrollInfo;我认为最大值是

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

scrollMax - largeChange + 1

这篇关于如何检测滚动条是否位于富文本框的末尾(vb.net)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆