Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to change font of Property Sheet?

How to change font of Property Sheet?

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Nikolay Denisov
    wrote on last edited by
    #1

    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:

    J 1 Reply Last reply
    0
    • N Nikolay Denisov

      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:

      J Offline
      J Offline
      James R Twine
      wrote on last edited by
      #2

      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.

      N 1 Reply Last reply
      0
      • J James R Twine

        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.

        N Offline
        N Offline
        Nikolay Denisov
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups