CEdit::CreateEX defaults Problems

Posted on 2000-04-11
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

Accepted Solution

inpras earned 100 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;    = 135;
      rect.right  = rect.left+ 260;
      rect.bottom = + 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
List out all word 7 257
CRON statement to run every 3 minutes except on Monday morning 12am to 2am 7 89
format the code in java 6 86
Sed question 2 68
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
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.
Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

912 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

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now