检测非标准滚动条

发布于 2024-10-11 19:29:15 字数 61 浏览 4 评论 0原文

有没有办法用 WinAPI 检测窗口是否有非标准滚动条(例如,窗口可以自己绘制滚动条而不是使用标准滚动条)?

Is there a way to detect with WinAPI if window has non-standard scrollbars (for example, window can draw scrollbars itself instead of using standard ones)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

不气馁 2024-10-18 19:29:15

我不太确定这是否有效,但这只是一个想法。
滚动条属于必须在启用此样式的情况下创建的窗口。因此,您可以检查您的窗口是否包含 WS_VSCROLL 样式,如果是,则这是标准滚动条。相反,它是由其他人绘制的。

您可以通过以下方式检查:

// Assume that a window handle hWnd is known
int style = GetWindowLong(hWnd, GWL_STYLE);
BOOL bStandard = ((style & WS_VSCROLL) != 0);

I'm not quite sure if this will work, but it is just an idea.
Scroll bars belong to the window which has to be created with this style enabled. So, you can check if your window contains WS_VSCROLL style and if so - this is standard scrollbar. In counterpart it is drawn by somebody else.

You can check it on this way:

// Assume that a window handle hWnd is known
int style = GetWindowLong(hWnd, GWL_STYLE);
BOOL bStandard = ((style & WS_VSCROLL) != 0);
很酷又爱笑 2024-10-18 19:29:15

很难看出你是如何做到这一点的。控件可以在自己的画布上绘制滚动条,进行自己的命中测试,您怎么可能知道。您无需为滚动条创建单独的 HWND 即可完成所有这些操作。

如果你能说出你为什么想知道这一点,那就更有趣了。

It's kind of hard to see how you could do this. A control could just paint scroll bars in its own canvas, do its own hit testing and how would you possibly know. You could do all this without creating separate HWNDs for the scroll bars.

What would be more interesting would be if you could say why you would wish to know this.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文