Enable Windows Cleartype for MFC Text Elements Created at Runtime

I have an MFC dialog program in which I create several CStatic and CEdit controls at runtime. Somehow the text in these controls is not enabled by Cleartype (Cleartype on Windows anti-aliases texts using subpixel positioning and coloring).

However, when one manually adds an Edit Control or Static Text at design time from the Visual Studio Toolbox, those controls include the ARE Cleartype.

So, somehow the controls from the toolbox are different from the controls created at runtime? Does anyone know how to enable Cleartype for runtime-generated text controls? Here's a snippet of the CStatic control in the OnCreate function of a dialog box:

CRect crc; crc.SetRect(100, 10, 300, 40);
m_static.Create(_T("Personeelsnummer?"), WS_CHILD | WS_VISIBLE, crc, this, IDC_STATIC1);

      

The text in this CStatic control is not included. Installing a different font has no effect.

I'm lost.

+2


source to share


1 answer


I found the answer to my question. The lack of cleartype controls generated at runtime is related to fonts. When you create the control at runtime, the default font is used, which is not affected by cleartype and should be replaced with a different font.



In my question, I noticed that I was trying to install a different font, however I created the font in a local function. After exiting the function where the font was set, the font was destroyed, so I couldn't see any difference. Now I have a class variable for the font that is destroyed only when the parent CWnd is damaged.

+3


source







All Articles