使用 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/