Why function Ellipse(...) are needed twice here to draw an ellipse?

Posted by John Son on Stack Overflow See other posts from Stack Overflow or by John Son
Published on 2012-09-21T14:24:36Z Indexed on 2012/09/21 15:37 UTC
Read the original article Hit count: 318

Filed under:
|
|

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: enter image description here mouse moving

when mouse button pops: enter image description here mouse button pops

Besides, what color of CBrush is if I use "CBrush brush; pDC->Ellipse(start.x,assist.y,end.x,end.y);"

© Stack Overflow or respective owner

Related posts about c++

Related posts about mfc