0

In my project I've 8 edit boxes and i need to set each box with different font. But my code is setting all the boxes single font.. So how can i modify it??

void CTrail3Dlg::OnBnClickedButton1()
{
    UpdateData(TRUE);
    CFontDialog dlg;
    // get font for current dialog, just to fill in LOGFONT
    LOGFONT lf;
    CFont *pFont = GetFont();
    pFont->GetLogFont(&lf);

    if (dlg.DoModal()== IDOK)
    {
        dlg.GetCurrentFont(&lf);
        m_font.DeleteObject();
        m_font.CreateFontIndirect(&lf);
        GetDlgItem(IDC_EDIT1)->SetFont(&m_font);
        GetDlgItem(IDC_EDIT2)->SetFont(&m_font);
        GetDlgItem(IDC_EDIT3)->SetFont(&m_font);
        GetDlgItem(IDC_EDIT4)->SetFont(&m_font);
        GetDlgItem(IDC_EDIT5)->SetFont(&m_font);
        GetDlgItem(IDC_EDIT6)->SetFont(&m_font);
        GetDlgItem(IDC_EDIT7)->SetFont(&m_font);
        GetDlgItem(IDC_EDIT8)->SetFont(&m_font);
    }
    // TODO: Add your control notification handler code here
}
2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by Ancient Dragon
0

You are just using the same font for all the edit boxes. If you want each one to have a different font then you need to create a font for each one. Make m_font an array and create separate fonts for each edit control.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.