Solved

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

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

ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
iSeries DB2 Query 2 95
Gotham fonts and Office 2013 6 89
How to convert MFC::CString to UTF8 wchar_t* 10 211
Is there a simple front-end menu system. 9 90
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…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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…

809 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