CEdit::CreateEX defaults Problems

Posted on 2000-04-11
Medium Priority
Last Modified: 2013-11-20
Hi I need to create some Cedit controls at runtime in my aplication. The problem I am having is this. I create the edit control and get the same look and border as a regular Edit box on all other screens but the Font is out to luch as per the System set fonts for window text. I need it to follow the windows Font isnt there an easier way than to Enum the fonts everytime and set the font to every one of my Runtime Edits. Here is the code I am using. Basically using this code I get an edit box with wrong font and size of font when I type on it.

m_ctlPartDescription.CreateEx(NULL, _T("EDIT"),_T(""),  

I get really old looking fonts. It definitely does not follow the system set font for that type of box.

Thanks again. Hope someone else has experienced that along with me cause I am stumped
Question by:Stevex2
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

inpras earned 300 total points
ID: 2705957
for that U have to set the font of edit control after creating it like this
      int   nIdentifier = 200;
      rect.left   = 30;
      rect.top    = 135;
      rect.right  = rect.left+ 260;
      rect.bottom = rect.top + 320;
      m_ctlPartDescription = new CEdit;
      m_ctlPartDescription->CreateEx( WS_EX_CLIENTEDGE,
                                   _T ("EDIT"),
      font = new CFont;
      font->CreateFont( -9,0, 0, 0, FW_NORMAL, 0, 0, 0,  
                                     ANSI_CHARSET,OUT_STROKE_PRECIS , CLIP_STROKE_PRECIS,
                                                 DRAFT_QUALITY,34, "MS Sans Serif");

I don't think there is another way...:)
Hope this helps

Expert Comment

ID: 2706843
Another solution is to set the edit control font to the same as the parent.

CFont* pFont = GetFont();

Featured Post

Percona Live Europe 2017 | Sep 25 - 27, 2017

The Percona Live Open Source Database Conference Europe 2017 is the premier event for the diverse and active European open source database community, as well as businesses that develop and use open source database software.

Question has a verified solution.

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

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses
Course of the Month12 days, 5 hours left to enroll

752 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