if you want to modify font of Dialog template More Information The following source shows how to load a DIALOG resource from memory and display it indirectly using a dialog template in memory. This function also uses the DLGINIT resource and will work with DIALOG resources that contain ActiveX controls. void CMainFrame::OnMyModalDialogIndirect() { //Load DLGTEMPLATE DLGTEMPLATE* pTemplate;
::UnlockResource(hTemplate); ::FreeResource(hTemplate); if (hDlgInit) { ::UnlockResource(hDlgInit); ::FreeResource(hDlgInit); } } if you want to modify font of dialog child controls, search the following articles in MSDN Q74043 HOWTO: Change the Color of an Edit Control Q98201 HOWTO: Change Dialog Box Background Color in MFC 2.0 or Later Q103786 HOWTO: Change Window Background Color with Foundation Classes Q117778 HOWTO: Change the Background Color of an MFC Edit Control Q132080 HOWTO: Change the Color of an MFC Child Control Class
$:可以重载对话框的虚函数virtual void OnSetFont(CFont* pFont);设置字体.$:可以响应WM_CTLCOLOR消息设置对话框或其控件的前景或文字颜色.
$:可以在应用程序类里调用void SetDialogBkColor( COLORREF COLORREF );一次设置所有对话框的文字和背景颜色
More Information
The following source shows how to load a DIALOG resource from memory and display it indirectly using a dialog template in memory. This function also uses the DLGINIT resource and will work with DIALOG resources that contain ActiveX controls.
void CMainFrame::OnMyModalDialogIndirect()
{
//Load DLGTEMPLATE
DLGTEMPLATE* pTemplate;
HINSTANCE hInst= AfxFindResourceHandle(
MAKEINTRESOURCE(IDD_INDIRECT),RT_DIALOG);
if (hInst == NULL)
{
TRACE("Cound not find resource in resource chain");
ASSERT(FALSE);
return;
}
HRSRC hRsrc = ::FindResource(hInst, MAKEINTRESOURCE(IDD_INDIRECT),
RT_DIALOG);
ASSERT(hRsrc != NULL); HGLOBAL hTemplate = ::LoadResource(hInst, hRsrc);
ASSERT(hTemplate != NULL);
pTemplate = (DLGTEMPLATE*)::LockResource(hTemplate); //Load coresponding DLGINIT resource
void* lpDlgInit;
HGLOBAL hDlgInit = NULL; HRSRC hsDlgInit = ::FindResource(hInst, MAKEINTRESOURCE(IDD_INDIRECT),
RT_DLGINIT);
if (hsDlgInit != NULL)
{
// load it
hDlgInit = ::LoadResource(hInst, hsDlgInit);
ASSERT(hDlgInit != NULL); // lock it
lpDlgInit = ::LockResource(hDlgInit);
ASSERT(lpDlgInit != NULL);
} //ToDo: Modify DLGTEMPLATE in memory if desired CDialog dlg;
dlg.InitModalIndirect(pTemplate, NULL, lpDlgInit);
dlg.DoModal();
::UnlockResource(hTemplate);
::FreeResource(hTemplate);
if (hDlgInit)
{
::UnlockResource(hDlgInit);
::FreeResource(hDlgInit);
}
}
if you want to modify font of dialog child controls, search the following articles in MSDN
Q74043 HOWTO: Change the Color of an Edit Control
Q98201 HOWTO: Change Dialog Box Background Color in MFC 2.0 or Later
Q103786 HOWTO: Change Window Background Color with Foundation Classes
Q117778 HOWTO: Change the Background Color of an MFC Edit Control
Q132080 HOWTO: Change the Color of an MFC Child Control Class