About the dialog question of CMFC

hello world 1 Reputation point
2020-05-17T13:20:07.623+00:00

question
recently I'm learning MFC dialog ,when I build a CFontDialog.I find i can only change the character pattern of the font,the color cannot be changed,I find some materials,but there aren't the result that I want to get in them.my IDE is vs.

void CMFCApplication1Dlg::OnBnClickedButton1()
{
 CFont* a = m_text.GetFont();
 LOGFONT logfont;
 a->GetLogFont(&logfont);
 CFontDialog dlg(&logfont);
 COLORREF color;
 if (dlg.DoModal() == IDOK)
 {
 m_font.Detach();
 LOGFONT temp;
 dlg.GetCurrentFont(&temp);;
 m_font.CreateFontIndirect(&temp);
 color=dlg.GetColor();
 m_text.SetFont(&m_font);
 CDC* pORIDC = GetDlgItem(IDC_EDIT1)->GetDC();
 HDC hdc = pORIDC->GetSafeHdc();
 SetTextColor(hdc,color);
 }
}
Not Monitored
Not Monitored
Tag not monitored by Microsoft.
35,935 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Dave Patrick 426.1K Reputation points MVP
    2020-05-18T01:06:36.507+00:00

    QnA currently supports the products listed here (more to be added) Better to reach out to subject matter experts in dedicated forums over here.

    https://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=vcgeneral

    (please don't forget to mark helpful replies as answer)

    --------------------------

    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows Server] Datacenter Management

    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees, and confers no rights.

    0 comments No comments