How do I fill a part of the view (in mfc vc++)with a color.Like say,I just drew a circle,how do I fill it with some color?

Recommended Answers

All 4 Replies

Read the manual perhaps?
Y'know, somewhere close to the part where you learnt how to draw a circle to begin with....

How do I fill a part of the view (in mfc vc++)with a color.Like say,I just drew a circle,how do I fill it with some color?

I assume you used the Ellipse method of the Device Context to draw your Circle. You used a Pen for the border.
Use a Brush for filling the circle.
Sample:

void CChildView::OnLButtonUp(UINT nFlags, CPoint point) 
{
	CClientDC dc(this);

	CPen border(PS_SOLID,1,0x000000FFL); //red border
	CPen * pOldPen;

	CBrush fill(0x0000FF00L); //green content
	CBrush * pOldBrush;

	pOldPen = dc.SelectObject(&border);
	pOldBrush = dc.SelectObject(&fill);

	dc.Ellipse(10,10,point.x,point.y);

        //deselect your objects to avoid memory leaks
	dc.SelectObject(pOldPen);
	dc.SelectObject(pOldBrush);

	CWnd ::OnLButtonUp(nFlags, point);
}

Best Regards
Ruediger

Oh thanks a lot.

Post removed
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.