I want to change the font style and font size of title/caption of Dialog(Derived from CDialog).Since caption/title is not associated with any resource id so i can't even use SetFont().Tell
Asked
Active
Viewed 562 times
-2
-
3https://stackoverflow.com/help/how-to-ask I suggest to avoid "urgent", "ASAP", we appreciate more context (is that MFC?) and what you have done so far, what failed what succeeded. – harper Oct 11 '19 at 10:05
-
Do skinning of entire dialog (use without system border) , which is pretty easy, by associating with a bitmap. – seccpur Oct 11 '19 at 10:11
-
This absolutely NOT easy (see above linked page). Avoid it and refer to Windows standard styling, which is a good reason not to change your dialog's title bar. – Nick Oct 11 '19 at 12:36
2 Answers
0
You could make a base class that does this, and then have all your dialog classes derive from this one. As long as you don't change the help id (m_nIDHelp), it should work for base classes. If not, you could add your own member variable to the base class to hold the ID of the dialog.
#include <afxpriv.h>
INT_PTR CModifyDialogDlg::DoModal()
{
CDialogTemplate templ;
if (!templ.Load(MAKEINTRESOURCE(m_nIDHelp))) // it could be different, but probably isn't
return -1;
templ.SetFont(_T("Comic Sans MS"), 16);
m_lpszTemplateName = NULL;
InitModalIndirect(templ.m_hTemplate);
return __super::DoModal();
}

Joseph Willcoxson
- 5,853
- 1
- 15
- 29
-
-
Sorry, but this attempt changes the font for items *inside* the dialog, but not for the caption. – Nick Oct 14 '19 at 08:23
-
Is derived from CDialog, but possibly CDialogEx.too, or another dialog class derived from either of those two. – Joseph Willcoxson Oct 14 '19 at 14:01
0
Sorry - I'm failing to format a comment - all hints I found don't work... So I post it as an answer here:
And another note: If you want to change the font for items in the dialog, don't refer to the help id, but to the resource id. Like this:
INT_PTR CModifyDialogDlg::DoModal()
{
dlgtemplate.Load(m_lpszTemplateName);
dlgtemplate.SetFont(ms_DefaultFontFace, (WORD)m_LogFontHeight);
DLGTEMPLATE *pDlgTemplate = (DLGTEMPLATE*)GlobalLock(dlgtemplate.m_hTemplate);
m_lpszTemplateName = NULL;
BOOL retVal = InitModalIndirect(pDlgTemplate);
GlobalUnlock(dlgtemplate.m_hTemplate);
return __super::DoModal();
}

Nick
- 472
- 3
- 18