I have a MFC dialog program in which I create a few CStatic and CEdit controls at runtime. Somehow the text in these controls aren't Cleartype enabled (Cleartype in Windows smoothes texts by sub-pixel positioning and coloring).
However, when one manually adds an "Edit Control" or a "Static Text" control at design time from the Visual Studio Toolbox these controls ARE Cleartype enabled.
So somehow the controls from the toolbox are different from the controls created at runtime? Does anyone know how to enable Cleartype for text controls created at runtime? Here's a code snippet of a CStatic control creation in the OnCreate function of the dialog:
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 Cleartype enabled. Setting a different font has no effect.
I'm lost.
I've found the answer to my own question. The lacking cleartype on the controls created at runtime is font-related. When one creates a control at runtime a default font is used which is unaffected by cleartype and should be replaced by a different font.
In my question I noted that I had tried setting a different font, however I had created a font in a local function. After exiting the function in which the font was set the font got destroyed so I didn't see any difference. I now have a class member variable for the font which is destroyed only when the parent CWnd gets destroyed.