// Get a pointer to the Edit box that contains the reply
CEdit * pEdit = (CEdit*)GetDlgItem(IDC_EDIT_REPLY);
// Trying to change the font of the Edit box so it is courier
CFont MyFont;
MyFont.CreateFont( 0,
0,
0,
0,
FW_REGULAR,
FALSE,
FALSE,
0,
ANSI_CHARSET,
OUT_TT_PRECIS,
CLIP_TT_ALWAYS,
PROOF_QUALITY,
TMPF_TRUETYPE|FF_MODERN,
"Courier New");
pEdit->SetFont(&MyFont);
Thanks,
Alan
----------------------
Alan K. Ismail
isma...@pitt.edu
I'm not a 100 percent sure about this but I believe you need to keep the
font you send to a control around. Your font is going out of scope. Try
creating your font in the constructure of the CEdit's parent and destroying
it in the CEdit's parent's destructor. I've done that before and it works.
Stephen Estes
>
>All I want to do is make the text in a CEdit window TT Courier New.
>Why isn't the following working? I keep ending up with the Fixed
>System font. I've tried "Arial" and others, but keep getting the 3.0
>FixedSys font. Chris? Anyone?
>
> // Get a pointer to the Edit box that contains the reply
> CEdit * pEdit = (CEdit*)GetDlgItem(IDC_EDIT_REPLY);
>
> // Trying to change the font of the Edit box so it is courier
>
> CFont MyFont;
> MyFont.CreateFont( 0,
> 0,
> 0,
> 0,
> FW_REGULAR,
> FALSE,
> FALSE,
> 0,
> ANSI_CHARSET,
> OUT_TT_PRECIS,
> CLIP_TT_ALWAYS,
> PROOF_QUALITY,
> TMPF_TRUETYPE|FF_MODERN,
> "Courier New");
>
> pEdit->SetFont(&MyFont);
The font you create has to exist for the lifetime of the control. It looks
to me as though your "MyFont" is a local variable in some function, is it?
If so, it will go out of scope when the function exits and be destroyed.
Try declaring the font variable "static" or make it a global or a data
member of whatever class contains your control.
Chris
--
--------------------------------------------------------------------------
| Chris Marriott, Warrington, UK | Author of SkyMap v2 shareware |
| ch...@chrism.demon.co.uk | astronomy program for Windows. |
| For more info, see http://www.winternet.com/~jasc/skymap.html |
| Author member of Association of Shareware Professionals (ASP) |
--------------------------------------------------------------------------