两个C++面向对象小程序问题
第一个有问题的程序
____________________________________________________________________________________________
void CExam2View::OnDraw(CDC* pDC)
{
CExam2Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
CRect rect1(100,100,200,200);
CPen*opPen;
opPen=(CPen*)pDC->SelectStockObject(BLACK_PEN);
pDC->Ellipse(rect1);
pDC->SelectObject(opPen);
CPen myPen(PS_SOLID,1,RGB(0,0,255));
opPen=pDC->SelectObject(&myPen);
pDC->Rectangle(300,100,400,200);
pDC->SelectObject(opPen);
CPen*pPen=new CPen(PS_SOLID,2,RGB(0,0,255));
opPen=pDC->SelectObject(pPen);
pDC->Rectangle(300,250,400,350);
pDC->SelectObject(opPen);
CPen myDefinePen;
LOGPEN logpen;
POINT width={30,0};
logPen.lopnStyle=PS_DASH;
logPen.lopnWidth=width;
logPen.lopnColor=RGB(255,0,0);
myDefinePen.CreatePenIndirect(&logPen);
opPen=pDC->SelectObject(&myDefinePen);
pDC->Rectangle(300,400,400,500);
pDC->SelectObject(opPen);
CRect rect2(500,100,600,200);
pDC->Ellipse(rect2);
}
下面代码是问题所在
----------------------------------------------------------
logPen.lopnStyle=PS_DASH;
logPen.lopnWidth=width;
logPen.lopnColor=RGB(255,0,0);
----------------------------------------------------------
第二个有问题的程序
____________________________________________________________________________________________
void CExam3View::OnDraw(CDC* pDC)
{
CExam3Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
pDC->TextOut(100,50,"****功夫不负有心人****");
COLORREF oColor,nColor;
nColor=RGB(192,192,192);
oColor=pDC->SetTextColor(nColor);
pDC->TextOut(100,70,"****功夫不负有心人****");
pDC->SetTextColor(oColor);
nColor=RGB(192,192,192);
oColor=pDC->SetBkColor(nColor);
pDC->TextOut(100,90,"****功夫不负有心人****");
pDC->SetTextColor(oColor);
pDC->SetTextColor(RGB(0,0,0));
CRect rect(100,110,600,130);
int widths[]={5,10,15,20,25,30,35,40,45,50,55,60,65,70};
pDC->ExtTextOut(100,110,ETO_OPAQUE,rect,"AAAAAAAAAAAAAAAA",widths);
CFont myFout;
myFont.CreateFont(25,15,60,30,FW_BOLD,TRUE,TRUE,0,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DRAFT_QUALITY,FIXED_PITGH|FF_SWISS,"myFont");
pDC->SelectObject(&myFont);
pDC->TextOut(100,200"AAAAAAAAAAAAAAAA");
}
希望高手们能发个详细步骤,小菜鸟期待您的指导,谢谢您。