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
}

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.