0

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?

3
Contributors
4
Replies
5
Views
8 Years
Discussion Span
Last Post by nerdinator
0

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

0

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

Edited by peter_budo: Adding tags to old thread

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.