确定矩形在窗口内是否可见

发布于 2024-09-29 18:57:12 字数 100 浏览 4 评论 0原文

我想确定窗口内的矩形是否完全可见。

我找到了 RectVisible,但该函数确定矩形的任何部分是否可见,我想知道整个矩形是否可见。

有没有这方面的功能?

I would like to determine if a rect inside a window is completly visible.

I have found RectVisible, but that function determines if any part of the rect is visible, I want to know if the entire rect is visible.

Is there any function for this?

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

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

发布评论

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

评论(4

握住你手 2024-10-06 18:57:12

首先使用 GetRandomRgn。在此处了解有关“系统区域”的更多信息。然后,偏移该区域,因为它位于屏幕坐标中(我链接的文章有一个示例)。之后,使用 从矩形创建一个区域CreateRectRgn 并将“矩形区域”的部分与不属于“系统区域”的部分组合起来:即调用 CombineRgn 将矩形区域作为第一个区域,将系统区域作为第二个区域,RGN_DIFF 作为 fnCombineMode。如果结果是 NULLREGION ,那么您的矩形是完全可见的 - 它没有完全或部分被任何窗口(顶层或非顶层)覆盖,或者它没有完全或部分离开屏幕。

总而言之,您很可能以错误的方式处理问题。如果您已经讲述了您一直在努力实现的目标,那么某人可能会建议一种更简单的方法。

First get the system clipping region (the visible region of a window) into a region by using GetRandomRgn. Read more about the 'system region' here. Then, offset that region since it is in screen coordinates (the article I linked has an example). After that, create a region from your rectangle with CreateRectRgn and combine the parts of your 'rectangle region' with those that are not part of the 'system region': that is calling CombineRgn passing the rectangle region as the first region, and the system region as the second region, and RGN_DIFF as the fnCombineMode. If the result is NULLREGION then your rectangle is fully visible - it is not fully or partially covered by any window (top level or not), or it is not fully or partially off-screen.

All in all, there's a probability that you're approaching your problem the wrong way around. If you've told what you've been trying to achieve someone could probably suggest a simpler approach.

一场春暖 2024-10-06 18:57:12

在每个角落使用 PtVisible长方形。

PtVisible 函数确定
指定点是否在范围内
设备的剪切区域
上下文。

Use PtVisible on each corner of the rectangle.

The PtVisible function determines
whether the specified point is within
the clipping region of a device
context.

尬尬 2024-10-06 18:57:12

你能用窗口和矩形的坐标做一个简单的比较吗?

检查矩形的左纵坐标是否位于窗口左边框的右侧;右纵坐标位于窗口右边框的左侧;顶部和底部类似吗?

唯一的问题可能是如果您同时使用逻辑坐标和物理坐标,在这种情况下您将需要执行转换。

Can you do a simple comparison using the coordinates of the window and the rectangle.

Check the rectangle's left ordinate is to the right of the Window's left border; the right ordinate is to the left of the Window's right border; and similar for top and bottom?

The only wrinkle might be if you are using both logical and physical coordinates, in which case you will need to perform a transformation.

幽梦紫曦~ 2024-10-06 18:57:12

所有处理剪辑矩形和点可见性的功能都与 Windows Vista 的新桌面合成功能无关。这些函数在 Windows XP 及更早版本以及关闭 Aero/Desktop Composition 的 Windows 7 上可以正常工作,但除此之外,它们将始终声称整个窗口可见。

All the functions that dealt with clip rectangles and point visibility broke with Windows Vista's new desktop composition feature. The functions will work fine on Windows XP and earlier, and on Windows 7 with Aero/Desktop Composition turned off, but otherwise, they will always claim that the entire window is visible.

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