MFC中CStatic文本的意外边框

时间:2015-11-03 02:29:05

标签: visual-c++ mfc

以下是代码实际绘制文本的摘录,类MineCStatic派生自CStatic,其成员m_textColor由客户端代码设置:

    SIZE si;
    if(::GetTextExtentPoint32(pDC->m_hDC, str, (int)str.GetLength(), &si))
    {
        CSize size = si;
        pDC->SetTextColor( m_textColor );
        pDC->SetBkMode(TRANSPARENT);
        DWORD style = GetStyle();
        if(m_bDrawTransparent)
            style &= ~SS_OWNERDRAW;
        if(style & SS_CENTER )
            pDC->TextOut((rect.Width()-size.cx)/2,(rect.Height()-size.cy)/2,str,str.GetLength());
        else if(style & SS_RIGHT)
            pDC->TextOut(rect.Width()-size.cx,(rect.Height()-size.cy)/2,str,str.GetLength());
        else
            pDC->TextOut(0,0,str,str.GetLength());

    }

结果如下(使用默认的黑色):

    m_title_font = new CFont;
    createFontResult = 
        m_title_font->CreateFont(64*rate,0,0,0,FW_HEAVY,FALSE, FALSE, 
        FALSE,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,
        CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH, "Arial");

        m_text.Create("0%",WS_EX_TRANSPARENT|SS_OWNERDRAW  ,rc,this,IDC_PATCH_CURRENTDATA);
        m_text.SetFont(m_title_font);  // MineCStatic instance

enter image description here

哪里有绿色边缘颜色?我怎样才能消除它。

0 个答案:

没有答案