我要设置一个tab页的标签的字体,代码如下
CFont*   pFont   = GetFont();
    
pFont->CreateFont(  -20, 0, 0, 0, 700, 0, 0, 0, 0, 0, 0, 0,  0, _T("宋体")  );m_myTabCtrl.SetFont(pFont);
请问下,我这样设置字体的大小对吗?谢谢回答。我的能修改成功,但是报错,不过可以忽略,错误如下
debug assertion failed!
file:wingdi.cpp
line:1120
for information on how your program can cause an assertion 
failure ,see the visual C++ documentation on asserts.
(press retry to debug the application)
谢谢回答

解决方案 »

  1.   

    CFont*  pFont  = new CFont; 
        
    pFont->CreateFont(  -20, 0, 0, 0, 700, 0, 0, 0, 0, 0, 0, 0,  0, _T("宋体")  ); m_myTabCtrl.SetFont(pFont); pFont->DeleteObject();
    delete pFont
    这样试试!
      

  2.   

    CFont*  pFont  = new CFont;
    pFont->CreateFont(
    -20,                        // nHeight
    0,                         // nWidth
    0,                         // nEscapement
    0,                         // nOrientation
    FW_NORMAL,                 // nWeight
    FALSE,                     // bItalic
    FALSE,                     // bUnderline
    0,                         // cStrikeOut
    GB2312_CHARSET,            // nCharSet
    OUT_DEFAULT_PRECIS,        // nOutPrecision
    CLIP_DEFAULT_PRECIS,       // nClipPrecision
    DEFAULT_QUALITY,           // nQuality
    DEFAULT_PITCH | FF_SWISS,  // nPitchAndFamily
    _T("宋体")));                 // lpszFacename
      

  3.   

    CFont*  pFont  = new CFont();
    pFont->CreateFont(  -20, 0, 0, 0, 700, 0, 0, 0, 0, 0, 0, 0,  0, _T("宋体")  );
    m_myTabCtrl.SetFont(pFont);
      

  4.   

    GetFont(); 是得到当前的字体,已经得到的字体又使用Create创建肯定会报错的。