}
}
}
dc.SetPixel(x,y,fill); x++; current=dc.GetPixel(x,y); x=s_point.x; x--;
current=dc.GetPixel(x,y);
while((current!=boundary)&&(current!=fill))
{
dc.SetPixel(x,y,fill); x--;
current=dc.GetPixel(x,y);
}
x=s_point.x;
说明:
(1)双击后,出现需填充的多边形,单击相关功能菜单实现区域填充。 (2)进行种子填充,需右击多边形内一点,作为开始填充的种子点。
void CMyView::OnLButtonDblClk(UINT nFlags, CPoint point) { }
RedrawWindow();
CDC* pDC=GetDC();
CPen newpen(PS_SOLID,1,RGB(255,0,0)); CPen *old=pDC->SelectObject(&newpen); spt[0]=CPoint(100,100); //绘制多边形区域 spt[1]=CPoint(300,100); spt[2]=CPoint(250,250); spt[3]=CPoint(100,250); spt[4]=CPoint(150,200); spt[5]=CPoint(90,180); spt[6]=CPoint(150,150); spt[7]=CPoint(100,100); pDC->Polyline(spt,8); pDC->SelectObject(old); ReleaseDC(pDC);
CView::OnLButtonDblClk(nFlags, point);
void CMyView::OnRButtonDown(UINT nFlags, CPoint point) { s_point=point; //选择种子点
CView::OnRButtonDown(nFlags, point);