问题描述
我有几个自定义绘制的CStatic,它们使用SetWindowRgn
为其赋予每个不规则(非矩形)形状.我需要使每个控件OnEraseBkgnd
后面的区域无效,为此,我想在父级CDialog
上使用CWnd::InvalidateRgn
,但是我需要将CRgn
转换为父级的坐标.我想要类似Cwnd::ScreenToClient(CRgn *)
的东西,但据我所知,不存在这样的东西.
I have several Custom Drawn CStatic which use SetWindowRgn
to give each of them an irregular (non-rectangular) shape. I need to Invalidate a the region behind each of these Controls OnEraseBkgnd
, for which I would like to use CWnd::InvalidateRgn
on the parent CDialog
however I need to translate the CRgn
into the coordinates of the parent. I would like to have something like Cwnd::ScreenToClient(CRgn *)
but as far as I can see no such thing exists.
我如何获得等价于CWnd::ScreenToClient
的CRgn?
How do I get the equivalent of CWnd::ScreenToClient
that takes a CRgn?
推荐答案
- 使用将
CRgn
区域拆分为矩形GetRegionData
-
ScreenToClient
单个矩形 - 使用
CreateFromData
将输出组合回区域 - Split
CRgn
region into rectangles usingGetRegionData
ScreenToClient
individual rectangles- Combine the output back into region using
CreateFromData
替代选项是 CRgn::OffsetRgn
使用从ScreenToClient
获得的单个点的距离来干扰该区域.
An alternate option is CRgn::OffsetRgn
to offet the region using the distance obtained from ScreenToClient
for an individual point.
这篇关于CRgn ScreenToClient的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!