Gdiplus::Graphics::DrawString绘制文字

 

    Gdiplus::FontFamily fontfm(_T("微软雅黑"));
    Gdiplus::Font font(&fontfm, 24, Gdiplus::FontStyleBold, Gdiplus::UnitPixel);
    /*
    参数1:FontFamily family 字体,如我们常见的 “宋体”、“仿宋”  、“微软雅黑”、 “Arial”等
    参数2:float emSize    字体大小
    参数3:FontStyle style     字体风格
            Regular,        //常规  
            Bold,           //加粗  
            Italic,         //倾斜  
            Underline,      //下划线  
            Strikout        //强调线    
    参数4:GraphicsUnit unit    指定单位
            Display,       //指定显示设备的度量单位。通常,视频显示使用的单位是像素;打印机使用的单位是 1/100 英寸。 
            Document,      //将文档单位(1/300 英寸)指定为度量单位。
            Inch,          //将英寸指定为度量单位。 
            Millimeter,    //将毫米指定为度量单位。
            Pixel,         //将设备像素指定为度量单位。 
            Point,         //将打印机点(1/72 英寸)指定为度量单位。
            World          //将世界坐标系单位指定为度量单位

    */

    HDC hdc = ::GetDC(m_hWnd);
    Graphics graphics(hdc);
    SolidBrush brush(Color(150, 0, 0, 255));

    graphics.DrawString(_T("我的名字叫李明"),-1,&font,PointF(10,10),&brush);//绘制文字

    

 

 

 

 

 

 

 

posted @ 2023-05-12 20:52  天子骄龙  阅读(480)  评论(0)    收藏  举报