VC 绘图技巧

自定义形状图形,定义几个点围城的图形,然后进行描边和填充:

 

if (m_memDC.m_hDC!=NULL)
	{
		CPoint point[4];
		point[0].x=nLeft+(int)(0.1*m_nWidth);
		point[0].y=m_nYmargin;

		point[1].x=nLeft+(int)(0.9*m_nWidth);
		point[1].y=m_nYmargin;

		point[2].x=nLeft+(int)(0.7*m_nWidth);
		point[2].y=(int)(0.2*m_nWidth)+m_nYmargin;

		point[3].x=nLeft+(int)(0.3*m_nWidth);
		point[3].y=(int)(0.2*m_nWidth)+m_nYmargin;

		CBrush br(m_crText);  //文字颜色
		CRgn rgn;
		rgn.CreatePolygonRgn(point,4,ALTERNATE);  //由所有点围城的不规则矩形
		m_memDC.FillRgn(&rgn,&br);   //填充该段

		br.DeleteObject();  //释放画刷
		rgn.DeleteObject();
		
		m_memDC.MoveTo(point[0]);
		m_memDC.LineTo(point[1]);
		
		m_memDC.MoveTo(point[1]);
		m_memDC.LineTo(point[2]);
		
		m_memDC.MoveTo(point[2]);
		m_memDC.LineTo(point[3]);
		
		m_memDC.MoveTo(point[3]);
		m_memDC.LineTo(point[0]);			
	}


 

 

 

 

你可能感兴趣的:(null,图形)