关于MFC图像处理中画笔的
void CUsePenView::OnDraw(CDC* pDC){
CUsePenDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
CPen * pPenOld,PenNew;
int nPenStyle[]={PS_SOLID, //实线
PS_DOT, //点线
PS_DASH, //虚线
PS_DASHDOT,//点划线
PS_DASHDOTDOT,//双点划线
PS_NULL, //空的边框
PS_INSIDEFRAME, //边框实线
};
char * strStyle[]={"Solid","Dot","Dash","DashDot","DashDotDot","Null","InsideFrame"};
pDC->TextOut(60,10,"用不同样式的画笔绘图");
for(int i=0;i<7;i++)
{
if(PenNew,CreatePen(nPenStyle[i],1,RGB(0,0,0)))
{
pPenOld=pDC->SelectObject(&PenNew);
pDC->TextOut(10,30+20*i,strStyle[i]);
pDC->MoveTo(100,40+20*i);
pDC->LineTo(200,40+20*i);
pDC->SelectObject(pPenOld);
PenNew.DeleteObject();
}
else
{
MessageBox("不能创建画笔!");
}
}
char * strWidth[]={"1","2","3","4","5","6","7"};
pDC->TextOut(260,10,"用不同宽度的画笔绘图");
for(int j=0;j<7;j++)
{
if(PenNew,CreatePen(PS_SOLID,j+1,RGB(0,0,0)))
{
pPenOld=pDC->SelectObject(&PenNew);
pDC->TextOut(260,30+20*j,strWidth[j]);
pDC->MoveTo(300,40+20*j);
pDC->LineTo(400,40+20*j);
pDC->SelectObject(pPenOld);
PenNew.DeleteObject();
}
else
{
MessageBox("不能创建画笔!");
}
}
char * strColor[]={"红","绿","蓝","黄","紫","青","灰"};
COLORREF rgbPenClr[]={RGB(255,0,0),RGB(0,255,0),RGB(0,0,255),RGB(255,255,0),
RGB(255,0,255),RGB(0,255,255),RGB(192,192,192)};
pDC->TextOut(460,10,"用不同颜色的画笔绘图");
for(int k=0;k<7;k++)
{
CPen *pPenNew=new CPen(PS_SOLID,2,rgbPenClr[k]);
pPenOld=pDC->SelectObject(&PenNew);
pDC->TextOut(460,30+20*k,strColor[k]);
pDC->MoveTo(500,40+20*k);
pDC->LineTo(600,40+20*k);
pDC->SelectObject(pPenOld); //恢复设备环境中原来的画笔
delete pPenNew ;
}
}
得出来的结果都是实黑线,怎么回事?有哪位大侠帮忙解决一下。