如何在MFC中将按钮标题加粗?

Aid*_*yan 1 mfc visual-c++

我在MFC对话框上有一个按钮.如何使文字变粗?

Sha*_*men 14

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);

      return TRUE;  // => system will set input focus to the first control item in the dialog box; (0 => you set the focus to a control of your choice)
}
Run Code Online (Sandbox Code Playgroud)