确定滚动条的当前位置是否超出最大/最小值 [英] Determine if scrollbar's current position is beyond maximal/minimal value
问题描述
我有一个 treeview控件我必须子类
。
一个我必须做的事情是处理 WM_MOUSEWHEEL
, WM_HSCROLL
和 WM_VSCROLL
正确地,如果用户滚动超出滚动条范围,则丢弃这些消息。
我尝试过使用 GetScrollInfo
像这样:
case WM_MOUSEWHEEL:
{
// 确定树视图控件是否具有可见的垂直滚动条
LONG_PTR WindowStyle = GetWindowLongPtr (hwnd,GWL_STYLE);
if (WindowStyle& WS_VSCROLL)
{
SCROLLINFO si;
ZeroMemory(& si, sizeof (si));
si.cbSize = sizeof (SCROLLINFO);
si.fMask = SIF_ALL;
GetScrollInfo(hwnd,SB_VERT,& si);
// 这里有问题:我不知道如何制定条件
if ( / * currentPosition> ; Min或currentPosition< Max value * / )
return 0L; // 无所事事处理
// 否则做我们的事情
}
}
返回 0L; // 如果滚动条不可见则无操作处理
所有3条消息的原则相同,因此我将此帖子限制为 WM_MOUSEWHEEL
,因此这篇文章可以简短。
我的问题如下:
如何确定用户是否滚动超出最大值/最小值?
谢谢。
祝你好运。
我无法想象用户可能会滚动超出其范围。此控件旨在将滚动位置保持在某个范围内。它是通过调用函数SetScrollRange
设置的:
http://msdn.microsoft.com/en-us/library/windows/desktop/bb787599%28v=vs.85%29。 aspx [ ^ ],
http:// msdn.microsoft.com/en-us/library/acw1066f.aspx [ ^ ]。
请参阅此文章: http://msdn.microsoft.com/en-us/library/ms997557.aspx [ ^ ]。
-SA
I have a treeview control that I must subclass
.
One of the things I must do is to handle WM_MOUSEWHEEL
, WM_HSCROLL
and WM_VSCROLL
properly, by discarding these messages if the user scrolls beyond the scrollbar range.
I have tried using GetScrollInfo
like this:
case WM_MOUSEWHEEL:
{
// determine if treeview control has visible vertical scrollbar
LONG_PTR WindowStyle = GetWindowLongPtr( hwnd, GWL_STYLE );
if( WindowStyle & WS_VSCROLL )
{
SCROLLINFO si;
ZeroMemory(&si, sizeof(si));
si.cbSize = sizeof(SCROLLINFO);
si.fMask = SIF_ALL;
GetScrollInfo( hwnd, SB_VERT, &si );
// here is the problem: I do not know how to formulate the condition
if( /* currentPosition > Min or currentPosition < Max value */ )
return 0L; // handle it by doing nothing
// otherwise do our stuff
}
}
return 0L; // if scrollbar is not visible handle it by doing nothing
The principle is the same for all 3 messages, so I will limit this post to WM_MOUSEWHEEL
only so this post can be brief.
My question is following:
How can I determine if the user scrolled beyond the maximal/minimal value ?
Thank you.
Best regards.
I cannot imagine that a user can possibly scroll beyond its range. This control is designed to keep the scroll position inside some range. It is set by the call to the functionSetScrollRange
:
http://msdn.microsoft.com/en-us/library/windows/desktop/bb787599%28v=vs.85%29.aspx[^],
http://msdn.microsoft.com/en-us/library/acw1066f.aspx[^].
Please see this article: http://msdn.microsoft.com/en-us/library/ms997557.aspx[^].
—SA
这篇关于确定滚动条的当前位置是否超出最大/最小值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!