VC:文本格式、文本输出函数(字体对象、字体结构变量、字体输出各函数)

        1、文本格式

      //创建新字体

       LOGFONT log;                                         //结构体变量

       CFont font;                                               //字体对象

       //属性设置

       log.lfCharSet=ANSI_CHARSET;

       log.lfClipPrecision=23;                       //字体的裁剪精度

       log.lfEscapement=0;                                  //字体相对于x轴的倾斜度为0

       log.lfHeight=50;                                //字体的高度为50

       strcpy(log.lfFaceName,"新建字体");    //字体名称

       log.lfItalic=0;                                    //0表示非斜体

       log.lfOrientation=900;                        //字体基准线与x轴之间夹角

       log.lfOutPrecision=90;                        // 字体的输出精度

       log.lfPitchAndFamily=0;                           // 字符间距

       log.lfQuality=90;                               //字体的输出质量

       log.lfUnderline=0;                              // 无下划线

       log.lfStrikeOut=0;                              //无删除线

       font.CreateFontIndirect(&log);            //创建字体

 

       pDC->SelectObject(&font);                 //选入设备环境

       //设置对齐方式

       pDC->SetTextAlign(TA_CENTER);

       //设置输出模式

       pDC->SetBkMode(TRANSPARENT);

       //设置字符间距为0

       pDC->SetTextCharacterExtra(0);

       pDC->TextOut(130,100,"样式1");

       //设置字符间距为10

       pDC->SetTextCharacterExtra(10);

       pDC->TextOut(130,150,"样式2");

2、文本输出函数

pDC->SetTextColor(RGB(200,0,0));
 int nTab[]={10,50,100};
 pDC->TabbedTextOut(100,50,"gl\thh\tgp",3,nTab,100);
 pDC->TextOut(100,90,"this is TesOout");
 pDC->ExtTextOut(100,130,ETO_CLIPPED,CRect(100,130,300,300),"tHis is ExTextOut",NULL);
 pDC->DrawText("This is DrawText",CRect(100,180,300,300),DT_WORDBREAK);

posted @ 2012-10-15 21:29  慧由心生  阅读(1069)  评论(0编辑  收藏  举报