使用Delphi / GDI从剪切区域中排除圆角矩形的正确方法是什么?
存在ExcludeClipRect以排除矩形区域,并且CreateRoundRectRgn与SelectClipRgn一起将剪切区域设置为圆形矩形.
但是如何从剪切区域中排除圆形矩形(类似于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.)