心寄笔端 附庸风雅

甘草的技术博客

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

1. SaveDC和RestoreDC.

说起来很费解,不如写个代码show下它们的能力~

// DCLib... ...
void Draw(HDC hdc)
{
// Draw a line (10, 10) - (190, 190)
MoveToEx(hdc, 10, 10, (LPPOINT)NULL);
LineTo(hdc, 190, 190);

// comments? [2]
SaveDC(hdc);

// comments? [1]
IntersectClipRect(hdc, 20, 20, 100, 100);

// Draw a rect [(10, 10) - (30, 30)]
RECT r = { 10, 10, 30, 30};
HBRUSH b = (HBRUSH)CreateSolidBrush(RGB(255, 0, 255));
FillRect(hdc, &r, b);

// comments? [2]
RestoreDC(hdc, -1);

MoveToEx(hdc, 20, 10, (LPPOINT)NULL);
LineTo(hdc, 190, 190);


int a = 0;
}



 

2. IntersectClipRect

可以用IntersectClipRect设定DC的可绘制范围(矩形),但是被Clip掉一部分的事实,怎么才能被Clear掉呢。

用SelectClipRgn(hdc, NULL);即可。

 

 

3. 

posted on 2011-11-05 11:40  甘草  阅读(269)  评论(0编辑  收藏  举报
Baidu
Google
心寄笔端
TEST
以后我会加上Power By的,先别介意