2009-05-07 25 views

Répondre

2

Vous pouvez créer un nouveau CFont et appeler WM_SETFONT sur le bouton. Quelque chose comme ceci:

// note: m_font is a class variable of type CFont 
m_font.CreateFont(10, 0, 0, 0, FW_BOLD, 0, 0, 0, 0, 0, 0, 0, 0, "Arial") 
GetDlgItem(IDC_BUTTON1)->SendMessage(WM_SETFONT, WPARAM(HFONT(font)), 0); 
+3

Bien sûr, vous devriez faire un getFont() -> GetLogFont() du bouton, modifier la propriété lfWeight de structure LOGFONT et de créer une nouvelle police sur cette base. – macbirdie

+0

merci @macbirdie, exactement ce que j'étais sur le point de suivre avec –

11
class CYourDialog : CDialog 
{ 
public: 
    virtual BOOL OnInitDialog(); // override 

private: 
    CButton m_button; 
    CFont m_font; 
}; 

BOOL CYourDialog::OnInitDialog() 
{ 
     __super::OnInitDialog(); 

     CFont* font = m_button.GetFont(); 

     LOGFONT logFont; 
     font->GetLogFont(&logFont); 
     logFont.lfWeight = FW_BOLD; 

     m_font.CreateFontIndirect(&logFont); 
     m_button.SetFont(&m_font); 
} 
Questions connexes