I am having a message window to display an error message. In that message some text should be bold and underlined. I am using static text. I am using the following code.
m_font.CreateFont(10,0,0,0,FW_BOLD,0,0,0,0,0,0,0,0,"Arial");
GetDlgfItem(Id of the lable)->SendMessage(WM_SETFONT,WPARAM(HFONT)),0);
Using this I can make it as bold. But I am not able change the boldness of the text. And how can I underline the text in the label.
Thanks in advance.
Try This
CWnd * pwnd = GetDlgItem(LABEL_ID);
CFont * pfont = pwnd->GetFont();
LOGFONT lf; pfont->GetLogFont(&lf);
lf.lfItalic = TRUE; //To Make Text Italic
lf.lfWeight = 500; //To Make BOLD, Use FW_SEMIBOLD,FW_BOLD,FW_EXTRABOLD,FW_BLACK
lf.lfUnderline = TRUE; //Underline Text
pfont->CreateFontIndirect(&lf);
pwnd->SetFont(pfont);
Or you can use
CFont *m_font;
m_font->CreateFont(10,0,0,0,FW_BOLD,0 , 1, 0, 0, 0, 0, 0, 0,_T("Arial"));
^^
//(for underline)
GetDlgItem(IDC_MOUSEPOS)->SetFont(m_font);