设置MFC控件字体【转】

来源:互联网 发布:四驱车 知乎 编辑:程序博客网 时间:2024/05/17 03:23

//设置标题字体
 CFont   *pFont   =   m_name.GetFont();

 

 LOGFONT   pLogFont;
 //TRACE( "Font:%p/n ",pFont);
 pFont-> GetLogFont(&pLogFont);

 LOGFONT   lf;
 memset(&lf,   0,   sizeof(LOGFONT));  
 lf.lfHeight   =pLogFont.lfHeight*2;                    
 lf.lfCharSet=pLogFont.lfCharSet;                          
 //strcpy((char*)(LPWTRSTR)lf.lfFaceName,(char*)(LPWTRSTR)pLogFont.lfFaceName);
 lstrcpy(/*(LPSTR)*/lf.lfFaceName/*LogFont.lfFaceName*/,(LPCWSTR)"黑体"/*"楷体_GB2312"*/);
 lf.lfWeight=700;
 lf.lfWidth=12;
 lf.lfHeight=30;
 CFont   *pNewFont   =new   CFont;
 pNewFont-> CreateFontIndirect(&lf);

                    

 m_name.SetFont(pNewFont);
 m_name2.SetFont(pNewFont);

原创粉丝点击