Solved

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

Posted on 1997-12-30
1
635 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

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 85
ASP.NET C# MessageBox.Show Showing a modal dialog box or form when the application ... 2 184
what font behind pdf 32 159
Problem to Office 1 39
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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…

680 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