关于使用裁减区域(ClipRgn)的问题
我的程序需要设置一个裁减区域,于是我在OnPaint里写了如下代码
void CChildView::OnPaint()
{
1 CPaintDC dc(this); // device context for painting
2 CRect rect(0, 0, 0, 0);
3 GetClientRect(&rect);
4 rect.left += 10;
5 CRgn rgn;
6 rgn.CreateRectRgnIndirect(&rect);
7 int nRet = dc.SelectClipRgn(&rgn, RGN_COPY); // 这个地方返回值为 2
8 if(nRet == NULLREGION) // NULLREGION = 1
9 {
10 TRACE("ClipRgn is NULL!\n");
11 }
12 rgn.DeleteObject();
...
//
13 CRect rectClip(0, 0, 0, 0);
14 nRet = dc.GetClipBox(&rectClip);
15 if(nRet ==NULLREGION)
16 {
17 TRACE("ClipRgn is NULL!\n");
18 }
...
}
有两个问题:
1.在第7行,如果使用 dc.SelectClipRgn(&rgn) 则返回NULLREGION,为什么会这样?
难道现在Windows只能使用ExtSelectClipRgn,而不能使用SelectClipRgn吗?
2.即使 dc.SelectClipRgn(&rgn, RGN_COPY) 成功(返回2或3),在后面(14行)的
dc.GetClipBox(&rectClip) 也会失败,请问是什么原因?