MFC-画笔与画刷的使用

  1. 定义画家CClientDC
  2. 定义画笔(CPen)或画刷(CBrush)
  3. 把画笔交给画家CDC::SelectObject

代码实现:

void CEventMessageView::OnDraw(CDC* pDC)
{
	CEventMessageDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	if (!pDoc)
		return;
	CPen cp(PS_SOLID,1,RGB(255,20,45));
	CPen* op = pDC->SelectObject(&cp);
	pDC->MoveTo(12, 30);
	pDC->LineTo(43, 78);

	pDC->SelectObject(op);
	pDC->Draw3dRect(65,20,34,45,RGB(0,0,234),RGB(234,0,0));

	CBrush brush(RGB(0, 255, 0));
	pDC->SelectObject(&brush);
	pDC->Ellipse(100, 20, 50, 50);
	
	// TODO: add draw code for native data here
}

猜你喜欢

转载自blog.csdn.net/qq_37774304/article/details/86514052