标签:blog http ar color sp on div 2014 art
在ondraw函数体里写上
int x,y;
CString outstr[6];
outstr[0]="五月棉花秀,";
outstr[1]="八月棉花干";
outstr[2]="像想起一朵不重开的花朵";
outstr[3]="或许你会想起我";
outstr[4]="花开天下暖";
outstr[5]="花落天下寒";
x=400;y=100;
CFont NewFont1;
NewFont1.CreateFont(30,30,0,0,FW_DONTCARE,false,false,false,DEFAULT_CHARSET, OUT_CHARACTER_PRECIS, CLIP_CHARACTER_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH|FF_DONTCARE, "黑体");
CFont *pOldFont;
pOldFont=pDC->SelectObject(&NewFont1);
pDC->SetTextColor(RGB(0,0,255));
pDC->TextOut(x,y,outstr[0]);
//第二个文本
TEXTMETRIC tm;
pDC->GetTextMetrics(&tm);
pDC->SetTextColor(RGB(0,255,0));
CSize strSize=pDC->GetTextExtent(outstr[0],outstr[0].GetLength());
x=x+strSize.cx ;//在它旁边输出
pDC->TextOut(x,y,outstr[1]);
//第三个文本 pDC->GetTextMetrics(&tm);
x=400;
y=y+tm.tmHeight+10*tm.tmExternalLeading;
CFont NewFont2;
NewFont2.CreateFont(25,25,0,0,FW_DONTCARE,false,true,false,DEFAULT_CHARSET, OUT_CHARACTER_PRECIS, CLIP_CHARACTER_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH|FF_DONTCARE, "黑体");
pDC->SelectObject(&NewFont2);
pDC->SetTextColor(RGB(255,0,0));
pDC->TextOut(x,y,outstr[4]);
//第四个 pDC->GetTextMetrics(&tm);
pDC->SetTextColor(RGB(105,105,105));
CSize strSize1=pDC->GetTextExtent(outstr[4],outstr[4].GetLength());
x=x+strSize.cx ;
pDC->TextOut(x,y,outstr[5]); //
CFont NewFont;
//实现竖直排列,注意"@system
NewFont.CreateFont(15,15,2700,0,FW_DONTCARE,false,false,false,DEFAULT_CHARSET, OUT_CHARACTER_PRECIS, CLIP_CHARACTER_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH|FF_DONTCARE, "@system");
pDC->SelectObject(&NewFont);
pDC->TextOut(100,100,outstr[2]);
pDC->TextOut(1200,100,outstr[3]);
结果如下:
标签:blog http ar color sp on div 2014 art
原文地址:http://www.cnblogs.com/lqs-zsjky/p/4158848.html