在VC6中使用CRgn类提供的方法实现。
1)利用CreateFromPath从绘制的路径中创建扇形区域。
2)利用CombineRgn对两个扇形区域进行与操作。
3)使用PtInRegion实现鼠标在扇形区域中的响应。
BOOL CPolyRGNDlg::OnInitDialog(){
bsh.CreateSolidBrush(RGB(255,0,0));
CClientDC dc(this);
CPoint p1,p2,p3,p4,p5;
p1 = CPoint(100,100);
p2 = CPoint(200,100);
p3 = CPoint(186,50);
p4 = CPoint(143,75);
p5 = CPoint(148,100);
CRect rt = CRect(0,0,200,200);//根据需要设置
CRect rt1 = CRect(50,50,150,150);//根据需要设置
dc.BeginPath();
dc.EndPath();
hRgn1.CreateFromPath(&dc);
//dc.InvertRgn(&hRgn1);
dc.BeginPath();
dc.EndPath();
falg = TRUE;
return TRUE; // return TRUE unless you set the focus to a control
}
void CPolyRGNDlg::OnPaint()
{
if(falg){
}else{
}
CClientDC dc(this);
dc.FillRgn(&hRgn2,&bsh);
bsh.DeleteObject();
}
void CPolyRGNDlg::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
if(PtInRegion(hRgn2,point.x,point.y)){
Invalidate(TRUE);
}
else{
Invalidate(TRUE);
}
CDialog::OnMouseMove(nFlags, point);
}
CRgn绘制扇形并响应鼠标move,布布扣,bubuko.com
原文:http://blog.csdn.net/zqckzqck/article/details/19930699