Solved

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

Posted on 1997-12-30
1
629 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
ID: 1313264
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
isEverywhere  challenge 19 82
post4 challenge 28 104
erros on link  checking 2 78
wordmultiple challenge 12 141
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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…

808 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