windows - 从剪裁区域中排除圆角矩形?

标签 windows delphi gdi

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

ExcludeClipRect排除一个矩形区域并且有CreateRoundRectRgn连同 SelectClipRgn将裁剪区域设置为圆角矩形。

但我怎样才能从剪辑区域中排除一个圆形矩形(类似于 ExcludeClipRoundRect 或 ExcludeClipRgn)?我试验了 CombineRgn但没有让它工作。

最佳答案

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

Region := CreateRectRgn (0, 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.)

关于windows - 从剪裁区域中排除圆角矩形?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19902899/

相关文章:

c++ - 将 CDC 窗口的内容导出到 EMF 文件

c# - 修改打印机特定配置对话框的属性

windows - 组合框下拉窗口可以显示在组合框窗口之外,如何?

windows - 如何在 Windows 8 中记录 DNS 故障(使用 PowerShell、cmd 或其他)

delphi - TDictionary 转换在引用的包中失败

delphi - 在 Delphi 中高效填充组合框

delphi - 我的“编译”对话框已消失。有可以控制的设置吗?

c - 在 win32/C/C++ 中共享内存和 IPC 的最快进程技术

c# - PC 上 XNA 中的信箱和缩放

windows - 使用 PowerShell 从注册表项中检索信息