How to adjust the "font" for the following:(solved)
fontSize 40
BOLD
Italicized
Thanks
The following fails:(now works)
CFont *myFont = new CFont();
myFont->CreateFont( 40, 0, 0, 0, FW_HEAVY, true, false,
0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
FIXED_PITCH|FF_MODERN, _T("Courier New") );
CEdit *ed1 = new CEdit();
ed1->Create(WS_VISIBLE | WS_BORDER,CRect(200,100,500,140),this,16);
ed1->SetFont(myFont);
Be sure not to delete myFont
as long as your edit control is still around.
Here what i did, and it run for me :
CFont m_Font;
CEdit m_EditBox
CClientDC dc(this);
int nFontSize = 40;
int nHeight = -((dc.GetDeviceCaps(LOGPIXELSY) * nFontSize) / 72);
m_Font.CreateFont(nHeight, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_CHARACTER_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, DEFAULT_PITCH | FF_SWISS, _T("Courier New"));
// Create edit box
if (m_EditBox.Create(WS_CHILD | WS_VISIBLE | WS_VSCROLL | ES_AUTOHSCROLL | ES_AUTOVSCROLL | ES_MULTILINE | ES_WANTRETURN | ES_READONLY, CRect(0, 0, 100, 100), this, 0x102) == FALSE) return FALSE;
// Set font
m_EditBox.SetFont(&m_Font, TRUE);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With