Change Font Type and Size

 

      

You can change font type, size of style of a dialog box's controls by writing few lines of code.

 

Sample Code:

Write this code OnInitDialog of your application. 

LOGFONT lf; // Used to create the CFont.

memset(&lf, 0, sizeof(LOGFONT)); // Clear out structure.

lf.lfHeight = 20; // Request a 20-pixel-high font

lf.lfWeight = FW_BOLD ;

strcpy(lf.lfFaceName, "Arial"); // with face name "Arial".

m_font.CreateFontIndirect(&lf); // Create the font.

// Use the font to paint a control. This code assumes

// a control named IDC_TEXT1 in the dialog box.

GetDlgItem(IDC_EDIT1)->SetFont(&m_font);

GetDlgItem(IDC_BROWSE)->SetFont(&m_font);

GetDlgItem(IDOK)->SetFont(&m_font);

GetDlgItem(IDCANCEL)->SetFont(&m_font);