Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

CWnd::SetFont() - Need help with this

25 views
Skip to first unread message

Alan Ismail

unread,
May 21, 1995, 3:00:00 AM5/21/95
to

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);


Thanks,
Alan
----------------------
Alan K. Ismail
isma...@pitt.edu


Stephen Estes

unread,
May 21, 1995, 3:00:00 AM5/21/95
to
In article <3pnros$g...@usenet.srv.cis.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

ses...@ix.netcom.com

Chris Marriott

unread,
May 22, 1995, 3:00:00 AM5/22/95
to
In article <3pnros$g...@usenet.srv.cis.pitt.edu>
aki...@pitt.edu "Alan Ismail" writes:

>
>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) |
--------------------------------------------------------------------------

0 new messages