Well I am trying to build a few small windows applications using MFC and trying to learn how things work, and while drawing a country’s flag I got stuck. Following lines of code draw three rectangles and a circle right at the center of middle rectangle, what need to do next is draw spokes in to circle, i.e 8 diameters separated by an angle of 45 degrees.
void CMainWindow::OnPaint (){
CPaintDC dc(this);
for (int i=0;i <=100;i+=50) {
dc.SetBkMode(TRANSPARENT);
CRect rect;
CPen pen(PS_SOLID, 1, RGB(0,0,0));
CPen *oldPen = dc.SelectObject(&pen);
if (i == 0){
CBrush brush(RGB(255,130,0));
CBrush *oldBrush = dc.SelectObject(&brush);
dc.Rectangle(75,(i+50),275,(i+100));
}
else if(i == 50) {
CBrush brush(RGB(255,255,255));
CBrush *oldBrush = dc.SelectObject(&brush);
dc.Rectangle(75,(i+50),275,(i+100));
CPen pen2(PS_SOLID, 1,RGB(0,0,255));
CPen *oldPen = dc.SelectObject(&pen2);
dc.Ellipse(150,100,200,150);
}
else {
CBrush brush(RGB(34,139,34));
CBrush *oldBrush = dc.SelectObject(&brush);
dc.Rectangle(75,(i+50),275,(i+100));
}
}
I have no clue how to do that, I tried to find it in the MFC library but no luck!
Here is an example of the sin() cos() method.
I didn’t see the point of putting the whole code block in a for loop, show I removed that part.