Windows区域学习1

区域是属于Windows GDI的概念;
区域是一个矩形、多边形或椭圆 (或两个或更多个形状的组合,); 可以填充、绘制、倒排、定框,并用于对光标执行命中测试;

VC新建一个单文档工程;添加三个菜单;

在视类的头文件加入成员变量,

HRGN hrgn1, hrgn2, hrgn3;

菜单单击函数如下;

void CTestrgnView::OnMenuitem32771() 
{
	// TODO: Add your command handler code here
	hrgn1 = ::CreateRectRgn(100, 100, 300, 300);
	HDC hdc1 = GetDC()->m_hDC;
	::SelectClipRgn(hdc1, hrgn1);
	//::TextOut(hdc1, 0, 0, "一些文字", 8);
	::MoveToEx(hdc1, 0, 0, NULL);
	::LineTo(hdc1, 200, 200);	
}

void CTestrgnView::OnMenuitem32772() 
{
	// TODO: Add your command handler code here
	hrgn2 = ::CreateEllipticRgn(400, 100, 700, 250);
	HDC hdc1 = GetDC()->m_hDC;
	//::SelectClipRgn(hdc1, hrgn2);
	HBRUSH hbrsh = ::CreateSolidBrush(RGB(50,150,50));
	::FillRgn(hdc1, hrgn2, hbrsh);
}

void CTestrgnView::OnMenuitem32773() 
{
	// TODO: Add your command handler code here
	POINT pt[6];
	p

你可能感兴趣的:(VC++,Rgn,Windows区域)