• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1052
  • Last Modified:

CEdit::CreateEX defaults Problems

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
Stevex2
Asked:
Stevex2
1 Solution
 
inprasCommented:
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
 
piano_boxerCommented:
Another solution is to set the edit control font to the same as the parent.

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

Featured Post

Technology Partners: 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!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now