怎么改变其内字体的大小?急等。

解决方案 »

  1.   

    别人写的一个变色CStatic
    #if !defined(AFX_ColorStatic_H__4CCD6BDB_9694_47EC_A643_42A2CEBF62DF__INCLUDED_)
    #define AFX_ColorStatic_H__4CCD6BDB_9694_47EC_A643_42A2CEBF62DF__INCLUDED_#if _MSC_VER > 1000
    #pragma once
    #endif // _MSC_VER > 1000class CColorStatic : public CStatic   //可设置背景颜色的静态框
    {public:// Overrides
    // ClassWizard generated virtual function overrides
    //{{AFX_VIRTUAL(CColorStatic)
    protected:
    virtual void PreSubclassWindow();
    //}}AFX_VIRTUALpublic:
    void SetText(LPCTSTR lpszText);protected:
    CFont m_font;
    CRect m_rc;
    CString m_strText;

    //{{AFX_MSG(CColorStatic)
    afx_msg void OnPaint();
    //}}AFX_MSG
    DECLARE_MESSAGE_MAP()
    };///////////////////////////////////////////////////////////////////////////////{{AFX_INSERT_LOCATION}}
    // Microsoft Visual C++ will insert additional declarations immediately before the previous line.#endif // !defined(AFX_ColorStatic_H__4CCD6BDB_9694_47EC_A643_42A2CEBF62DF__INCLUDED_)
    #include "stdafx.h"
    #include "resource.h"
    #include "ColorStatic.h"#ifdef _DEBUG
    #define new DEBUG_NEW
    #undef THIS_FILE
    static char THIS_FILE[] = __FILE__;
    #endifBEGIN_MESSAGE_MAP(CColorStatic, CStatic)
    //{{AFX_MSG_MAP(CColorStatic)
    ON_WM_PAINT()
    //}}AFX_MSG_MAP
    END_MESSAGE_MAP()void CColorStatic::OnPaint() 
    {
    CPaintDC dc(this);  dc.FillSolidRect(m_rc,RGB(123,156,235)); //绘制背景 dc.SelectObject(&m_font);  
    dc.SetBkMode(TRANSPARENT); //设置背景透明
    dc.SetTextColor(RGB(255,255,255)); //设置文字颜色为白色
    dc.DrawText(m_strText.GetBuffer(0),m_strText.GetLength(),&m_rc,DT_SINGLELINE | DT_VCENTER | DT_LEFT | DT_PATH_ELLIPSIS);
    }void CColorStatic::SetText(LPCTSTR lpszText)
    {
    m_strText = lpszText;
    Invalidate();  
    }
    /********************************************************************/
    /* */
    /* Function name : PreSubclassWindow */
    /* Description   : Initialize control variables */
    /* */
    /********************************************************************/
    void CColorStatic::PreSubclassWindow() 
    {
    GetClientRect(m_rc); m_font.CreateFont(12, 0,0,0,FW_BOLD, 0,0,0,
    DEFAULT_CHARSET, OUT_CHARACTER_PRECIS, CLIP_CHARACTER_PRECIS,
    DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "宋体");

    CStatic::PreSubclassWindow();
    }
      

  2.   

    m_CtrlText.Create("创建CStatic控件", WS_CHILD|WS_VISIBLE, CRect(0,0,0,0), this, 33);
    m_NormalFont.CreateFont(-16,0,   0,0,400,   0,0,0,   134,   3,2,1,   49,"隶书");
    m_CtrlText.SetFont(&m_NormalFont);在OnCreate里写
      

  3.   

    CFont m_font;放到类声明里
    CFont* pFont = GetDlgItem(IDC_STATIC1)->GetFont();
    LOGFONT lf;
    pFont->GetLogFont(&lf);
    lf.lfWidth = 7;
    lf.lfHeight = 14;
    lf.lfWeight =650;
    //strcpy(lf.lfFaceName, _T("Arial"));
    m_font.CreateFontIndirect(&lf);   
    GetDlgItem(IDC_STATIC1)->SetFont(&m_font);