Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 660
  • Last Modified:

Font in a property page , how could i set it ?

I start a new CPropertySheet , with which i add 3 CPropertyPage , but when i create them by implementing my ressource did with Visual C++ , all works except Control with WS_STATICEDGE State (got an Assert) and if i set a Font like Arial , Size 9 , it's always default font which appears
how could i overload the default params ?
 
please , give code source with ;)

Earn da point , and learn me !! yeahh ! Greetings
0
SkizoWalker
Asked:
SkizoWalker
1 Solution
 
WBerthinCommented:
Hi SkizoWalker,

You cannot use extended windows styles in property pages,
as they are not supported. That means you have to avoid styles
like  Client Edge, Static Edge and Modal Frame.
Use instead styles like Sunken and Border. These are not
extended styles and they are supported in Property Pages.

You can create you own font in a property page.
You simply add a DDX control variable to each control
that needs the special font. Use the Member Variables
tab in Class Wizard, click the Add Variable Button and
be sure to set the Category to "Control" in the Category
Combo Box.  Then in OnInitDialog create your own font
using CreateFont and attach it to the control using SetFont.

The code to do this is a follows:

// IN THE HEADER FILE
//DECLARE OUR SPECIAL FONT
CFont* m_pFont;

//AND USE CLASS WIZARD TO ADD A CONTROL VARIABLE
//FOR EACH CONTROL THAT NEEDS A SPECIAL FONT
// Dialog Data
//{{AFX_DATA(CMyPropertyPage11)
enum { IDD = IDD_PROPPAGE11 };
CStatic      m_ctrlStatic1;
//}}AFX_DATA


//IN THE cpp FILE
//SET m_pFont TO NULL IN THE CONSTRUCTOR
CMyPropertyPage11::CMyPropertyPage11() : CPropertyPage(CMyPropertyPage11::IDD)
{
      m_pFont = NULL;
      //{{AFX_DATA_INIT(CMyPropertyPage11)
   // NOTE: the ClassWizard will add member initialization here
      //}}AFX_DATA_INIT
}

//CLASS WIZARD WILL ADD A CONTROL VARIABLE
//FOR EACH CONTROL THAT NEEDS A SPECIAL FONT
void CMyPropertyPage11::DoDataExchange(CDataExchange* pDX)
{
      CPropertyPage::DoDataExchange(pDX);
      //{{AFX_DATA_MAP(CMyPropertyPage11)
      DDX_Control(pDX, IDC_STATIC1, m_ctrlStatic1);
      //}}AFX_DATA_MAP
}

//OVERRIDE OnInitDialog TO CREATE THE SPECIAL FONT
//AND ATTACH IT TO EACH CONTROL USING IT
BOOL CMyPropertyPage11::OnInitDialog()
{
      CPropertyPage::OnInitDialog();

      //CREATE SPECIAL FONT
      m_pFont = new CFont();
      CDC* pDC = GetDC();
      int nFontHeight =
            -( (9 * pDC->GetDeviceCaps(LOGPIXELSY)) / 72 );
      ReleaseDC(pDC);
      m_pFont->CreateFont(
             nFontHeight, 0, 0, 0, FW_NORMAL, 0, 0, 0,
           DEFAULT_CHARSET, OUT_CHARACTER_PRECIS,              CLIP_CHARACTER_PRECIS,
           DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE,              "Arial");

      //ADD SPECIAL FONT TO THE CONTROL
      m_ctrlStatic1.SetFont(m_pFont);

      return TRUE;  
        // return TRUE unless you set the focus to a control            // EXCEPTION: OCX Property Pages should return FALSE
}

This code worked just fine for me, so let me know if
you have any problem with it.

0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now