微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

windows – 从剪切区域中排除圆角矩形?

使用Delphi / GDI从剪切区域中排除圆角矩形的正确方法是什么?

存在ExcludeClipRect以排除矩形区域,并且CreateRoundRectRgnSelectClipRgn一起将剪切区域设置为圆形矩形.

但是如何从剪切区域中排除圆形矩形(类似于ExcludeClipRoundRect或ExcludeClipRgn)?我用CombineRgn进行了实验,但没有得到它的工作.

解决方法

感谢@TLama的评论我能够像这样解决它:

Region := CreateRectRgn (0,ClientWidth,ClientHeight);
ExcludedRegion := CreateRoundRectRgn (1,1,ClientWidth - 1,ClientHeight - 1,3,3);
CombineRgn (Region,Region,ExcludedRegion,RGN_XOR);
SelectClipRgn (Canvas.Handle,Region);

之前的问题是尚未创建作为CombineRgn的第一个参数传递的区域.链接教程中的一句话提供了线索:

One more thing to point out is that the destination region in
CombineRgn can be one of the source regions.

连同MSDN的这些信息:

hrgnDest [in]: A handle to a new region with dimensions defined by combining two other regions. (This region must exist before CombineRgn is called.)

原文地址:https://www.jb51.cc/windows/612861.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐