Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » CExtLabel's font on a CView derived class Collapse All
Subject Author Date
jb lee Dec 12, 2006 - 5:49 AM

Hi,
Is it possible to change the font of a CExtLabel on the CView derived class?
At first, I made the control as CStatic, creating font and setfont, the label shown well.
After change the control as CExtLabel, nothing is appeared on the control.
If the font setting code is commented, the text appeared.

What’s wrong with me?

Regards,
jb.

Technical Support Dec 12, 2006 - 1:14 PM

We failed to reproduce this bug. We used the following code for testing:

CExtLabel m_wndLabel;

...

m_wndLabel.Create(
    _T("Some Text"),
    WS_VISIBLE|WS_CHILD,
    CRect(300,300,400,400),
    this
    );
m_wndLabel.SetFont( &g_PaintManager->m_FontBold );
Would you send us a test project that demonstrates the problem?

jb lee Dec 14, 2006 - 6:54 AM

Your code works.

But, I wanna use custom font for the control. for example,

    CFont font;
    VERIFY(font.CreateFont(
     theAppSetting->get_setting("View", "FontHeight", 13), // nHeight
     0, // nWidth
     0, // nEscapement
     0, // nOrientation
     FW_NORMAL, // nWeight
     FALSE, // bItalic
     FALSE, // bUnderline
     0, // cStrikeOut
     ANSI_CHARSET, // nCharSet
     OUT_DEFAULT_PRECIS, // nOutPrecision
     CLIP_DEFAULT_PRECIS, // nClipPrecision
     DEFAULT_QUALITY, // nQuality
     DEFAULT_PITCH | FF_SWISS, // nPitchAndFamily
     theAppSetting->get_setting("View", "FontName", "굴림체").c_str())); // lpszFacename
    m_Title.SetFont(&font);

Technical Support Dec 15, 2006 - 4:31 AM

You created the CFont object on the stack. The font variable is local in the scope of the method where you set the font. That means it will be destroyed after the method completes. You should create the CFont object dynamically or declare it in the class declaration section.