can not change text size of Button in Visual C++

Ahmet Orun 20 Reputation points


I just want to change the Text size of a "Button" in MFC Visual C++ project but after hours of searching in internet and trying all suggestions "no solution " at all. This is really unbelievable !!

A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,604 questions
{count} votes

Accepted answer
  1. Minxin Yu 10,616 Reputation points Microsoft Vendor

    Hi, @Ahmet Orun

    Please refer to the similar thread: How to set font for single control in Dialog?
    And RLWA32's answer:


    	// TODO: Add extra initialization here
    	// class member 	CFont m_NewFont;
    	LOGFONT lf{};
    	CFont* pFont = m_button1.GetFont(); // Get initial font
    	pFont->GetLogFont(&lf); // Use LOGFONT to get font information
    	lf.lfHeight = 120; // Use to create 12 point font
    	m_NewFont.CreatePointFontIndirect(&lf); // Create a 12 point font
    	m_button1.SetFont(&m_NewFont, TRUE); // Have edit control use the 12 point font
    	return TRUE;   

    Best regards,

    Minxin Yu

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. uncle_Kei 0 Reputation points

    To change the text size of a button, the font used for its text display must itself be changed.

    So you create a new font and SetFont() it to the button.

    If you want to change only the text size, it is more complicated, first querying the metric of the currently used font,

    Then, a new font with only the size changed is created from that information and SetFont() is performed.

    If the button is on a dialog, you can also put the font size in that resource, as in the following example.This method affects all controls belonging to the dialog in question.

    DIALOGNAME DIALOGEX 0, 0, 300, 100


    FONT 10, "MS UI Gothic", 400, 0, 0x1