How to change font of Property Sheet?
-
Can anyone tell me if the following code is correct: class CMyPropertySheet : public CPropertySheet { // ... public: virtual int DoModal(); protected: static int CALLBACK PropSheetProc( HWND hwndDlg, UINT uMsg, LPARAM lParam ); } class CMyDialogTemplate : public CDialogTemplate { friend CMyPropertySheet; } int CMyPropertySheet::DoModal() { m_psh.dwFlags |= PSH_USECALLBACK; m_psh.pfnCallback = PropSheetProc; return CPropertySheet::DoModal(); } int CALLBACK CMyPropertySheet::PropSheetProc( HWND hwndDlg, UINT uMsg, LPARAM lParam ) { switch ( uMsg ) { case PSCB_PRECREATE: { LPDLGTEMPLATE pTemplate = ( LPDLGTEMPLATE )lParam; CMyDialogTemplate dlgTemplate; dlgTemplate.m_hTemplate = ::GlobalHandle( pTemplate ); dlgTemplate.m_dwTemplateSize = CMyDialogTemplate::GetTemplateSize( pTemplate ); dlgTemplate.SetFont( _T("Tahoma"), 8 ); dlgTemplate.Detach(); break; } default: break; } return 0; } I am in doubt if it is allowed to modify property sheet template this way. Although I have tried it out on NT4 and everything looked just fine. Regards, Nikolay :confused:
-
Can anyone tell me if the following code is correct: class CMyPropertySheet : public CPropertySheet { // ... public: virtual int DoModal(); protected: static int CALLBACK PropSheetProc( HWND hwndDlg, UINT uMsg, LPARAM lParam ); } class CMyDialogTemplate : public CDialogTemplate { friend CMyPropertySheet; } int CMyPropertySheet::DoModal() { m_psh.dwFlags |= PSH_USECALLBACK; m_psh.pfnCallback = PropSheetProc; return CPropertySheet::DoModal(); } int CALLBACK CMyPropertySheet::PropSheetProc( HWND hwndDlg, UINT uMsg, LPARAM lParam ) { switch ( uMsg ) { case PSCB_PRECREATE: { LPDLGTEMPLATE pTemplate = ( LPDLGTEMPLATE )lParam; CMyDialogTemplate dlgTemplate; dlgTemplate.m_hTemplate = ::GlobalHandle( pTemplate ); dlgTemplate.m_dwTemplateSize = CMyDialogTemplate::GetTemplateSize( pTemplate ); dlgTemplate.SetFont( _T("Tahoma"), 8 ); dlgTemplate.Detach(); break; } default: break; } return 0; } I am in doubt if it is allowed to modify property sheet template this way. Although I have tried it out on NT4 and everything looked just fine. Regards, Nikolay :confused:
Small question... Why not use SetFont in the CPropertyPage-derived class(es)? You can use it in CPropertyPage::OnInitDialog(...). You can set the font for the dialog, and its controls right there. -=- James.
-
Small question... Why not use SetFont in the CPropertyPage-derived class(es)? You can use it in CPropertyPage::OnInitDialog(...). You can set the font for the dialog, and its controls right there. -=- James.
Because I set the desired font for my CPropertyPages in the Resource Editor (although MFC ignores font settings for CPropertyPages in the Resource Editor :-D, it could be easily solved by overriding CPropertySheet::BuildPropPageArray()), and at run-time, I want to set the sheet's FONT to be the same and SIZE everything correctly. Unfortunately, the Windows Property Sheet control was designed so that it always uses the system font for the sheet. So the problem is that I need to specify somehow the desired font for the CPropertySheet itself. Above is my solution. Regards, Nikolay