Solved

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

Posted on 1997-12-30
1
612 Views
Last Modified: 2013-12-03
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
Comment
Question by:SkizoWalker
1 Comment
 
LVL 1

Accepted Solution

by:
WBerthin earned 100 total points
Comment Utility
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now