Solved

CEdit::CreateEX defaults Problems

Posted on 2000-04-11
2
940 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
2 Comments
 
LVL 4

Accepted Solution

by:
inpras earned 100 total points
Comment Utility
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
Comment Utility
Another solution is to set the edit control font to the same as the parent.

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

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
MFC Dialog 9 47
ODBC Connection Logging, ADO.NET 6 49
Detect CR LF to each line 12 135
Hibernate methods 2 58
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…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

763 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

7 Experts available now in Live!

Get 1:1 Help Now