Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

CEdit::CreateEX defaults Problems

Posted on 2000-04-11
2
Medium Priority
?
1,033 Views
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(""),  
            WS_VISIBLE|WS_TABSTOP|WS_CHILD|WS_BORDER|ES_AUTOHSCROLL, rect, GetDlgItem(IDC_PART_TABS), IDC_PART_DESCRIPTION);

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
0
Comment
Question by:Stevex2
[X]
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
2 Comments
 
LVL 4

Accepted Solution

by:
inpras earned 300 total points
ID: 2705957
Hi
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"),
                                           NULL,
                                           WS_CHILD|WS_VISIBLE|WS_TABSTOP|WS_BORDER|ES_AUTOHSCROLL|ES_LEFT,
                                           rect,
                                           this,
                                           nIdentifier);
      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");
      m_ctlPartDescription->SetFont(font);

I don't think there is another way...:)
Hope this helps
inpras
0
 
LVL 4

Expert Comment

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

CFont* pFont = GetFont();
pEdit->SetFont(pFont);
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
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.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

610 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