Why function Ellipse(...) are needed twice here to draw an ellipse?
- by John Son
MFC:
I read this code which is to draw an ellipse (not solid interior), but I cannot understand why function "pDC-Ellipse(...)" is needed twice here?
CDC *pDC=GetDC();
CPen pen;
CBrush brush;
getpen(pen,pDC,col,bol);
if(do_what>=DRAW_LINE&&do_what<=DRAW_RRECT){
p->p[0]=start;
p->p[1]=end;
if(sol==1){
getbrush(brush,pDC,col);
}
if(do_what==DRAW_LINE){
pDC->MoveTo(start);
pDC->LineTo(end);
}
else if(do_what==DRAW_ELLIPSE||do_what==DRAW_CIRCLE){
pDC->SetROP2(R2_NOT);
assist=start;
if(do_what==DRAW_CIRCLE){
assist.y=end.y-end.x+start.x;
}
pDC->Ellipse(start.x,assist.y,end.x,end.y);
pDC->SetROP2(R2_COPYPEN);
if(sol==0){
pDC->SelectStockObject(NULL_BRUSH);
}
if(do_what==DRAW_CIRCLE){
assist.y=point.y-point.x+start.x;
}
pDC->Ellipse(start.x,assist.y,point.x,point.y);
end=point;
}
}
If I remove the first one, the ellipse will be black solid inside.
If I remove the second one, the ellipse will never be drawn but disappears when left mouse button is up.
the dialog:
when moving mouse:
mouse moving
when mouse button pops:
mouse button pops
Besides, what color of CBrush is if I use
"CBrush brush; pDC-Ellipse(start.x,assist.y,end.x,end.y);"