MFC画刷2

void CNeiCunDlg::InHuaBi()
{
	CWnd *pWnd=GetDlgItem(IDC_STATIC);
	if(pWnd!=NULL)
	{
		CPaintDC dc(pWnd);
		dc.SetBkMode(TRANSPARENT);
		CPen linepen1(PS_SOLID,1,RGB(192,192,192));
		CPen linepen3(PS_DASH,1,RGB(192,192,192));
		CPen linepen2(PS_SOLID,1,RGB(255,0,0));
		CPen *poldpen;
		poldpen=dc.SelectObject(&linepen1);
		//画Y轴
		//dc.MoveTo(35,35);
		//dc.LineTo(35,335);

		CBrush brush[6];
		brush[0].CreateSolidBrush(RGB(0,255,255));
		brush[1].CreateSolidBrush(RGB(0,255,0));
		brush[2].CreateSolidBrush(RGB(0,0,255));
		brush[3].CreateSolidBrush(RGB(255,255,0));
		brush[4].CreateSolidBrush(RGB(255,0,255));
		brush[5].CreateSolidBrush(RGB(255,255,255));

		dc.SelectObject(&brush[0]);
		dc.Rectangle(100,170,120,180);
		dc.TextOut(125,165,"已占用");

		dc.SelectObject(&brush[5]);
		dc.Rectangle(200,170,220,180);
		dc.TextOut(225,165,"未占用");

		dc.SelectObject(&brush[5]);
		dc.Rectangle(25,200,537,250);
}
}
刷新画刷:Invalidate();

你可能感兴趣的:(MFC画刷2)