Pra*_*rin 1 mfc mfc-feature-pack
我有一个消息窗口来显示错误消息。在该消息中,某些文本应加粗并加下划线。我正在使用静态文本。我正在使用以下代码。
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);
Run Code Online (Sandbox Code Playgroud)
使用这个我可以让它变得大胆。但我无法改变文本的粗体。以及如何在标签中的文本下划线。
提前致谢。
尝试这个
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);
Run Code Online (Sandbox Code Playgroud)
或者你可以使用
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);
Run Code Online (Sandbox Code Playgroud)
http://msdn.microsoft.com/en-us/library/2ek64h34.aspx
归档时间: |
|
查看次数: |
7537 次 |
最近记录: |