码迷,mamicode.com
首页 > 其他好文 > 详细

多个字符串输出,竖直输出

时间:2014-12-12 01:18:06      阅读:649      评论:0      收藏:0      [点我收藏+]

标签: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]);

结果如下:

 

bubuko.com,布布扣bubuko.com,布布扣
bubuko.com,布布扣

 

多个字符串输出,竖直输出

标签:blog   http   ar   color   sp   on   div   2014   art   

原文地址:http://www.cnblogs.com/lqs-zsjky/p/4158848.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!