Click to See Complete Forum and Search --> : Change Font in EditBox


AcID_
September 17th, 1999, 02:07 AM
How can I change font in EditBox?
Thanx.

Oleg Lobach
September 17th, 1999, 02:20 AM
In OnInitDialog try use this:

CWindowDC dcText(&m_MyEdit);
CFont* pFont=dcText.GetCurrentFont( );
LOGFONT lf;
pFont->GetLogFont(&lf);
// For instance:
lf.lfUnderline =TRUE;//Change font to be underlined
m_Font.CreateFontIndirect (&lf)
m_MyEdit.SetFont(&m_Font);




where m_Font declared as CFont , m_MyEdit declared as CEdit in your CDialog derived.

At run-time you can get a pointer to CEdit using GetDlgItem:
CEdit *pEdit=(CEdit *)GetDlgItem(ID_EDIT1);


Hope this helps,
Oleg.

AcID_
September 17th, 1999, 02:40 AM
Thanx, your hopes comes true, and i found another way.

LOGFONT lf;
GetDlgItem(IDC_OUTPUT)->GetFont()->GetLogFont(&lf);

strcpy(lf.lfFaceName, "Fixedsys");
fnt.CreateFontIndirect(&lf);
GetDlgItem(IDC_OUTPUT)->SetFont(&fnt);