Set font Courier for Edit box (VC++6.0) ???
-
hi everybody. I need data in edit box : 5 line, 1 line max = 50 characters. then I must set font Courier for Edit box. i using code: ... ::OnInitDialog() { CFont m_Font; VERIFY(m_Font.CreateFont( 12, // nHeight 0, // nWidth 0, // nEscapement 0, // nOrientation FW_NORMAL, // nWeight FALSE, // bItalic FALSE, // bUnderline 0, // cStrikeOut ANSI_CHARSET, // nCharSet OUT_DEFAULT_PRECIS, // nOutPrecision CLIP_DEFAULT_PRECIS, // nClipPrecision DEFAULT_QUALITY, // nQuality DEFAULT_PITCH | FF_SWISS, // nPitchAndFamily "Courier")); // lpszFacename CWnd *pWnd = GetDlgItem(IDC_MESSAGE_TEXT); pWnd->SetFont(&m_Font); m_Font.DeleteObject(); ... } =>Data in Edit text is Bold. When I using mouse to choice this Edit text , it show text wrong. seem, it need control of mouse. for example: show text wrong when type : "y" or "g", it have lost under. i wish you help me. thanks very much. **) when using all character UPPER ==> 1 line don't show 50 character. hope your help. thanks very much regards
nothing
-
hi everybody. I need data in edit box : 5 line, 1 line max = 50 characters. then I must set font Courier for Edit box. i using code: ... ::OnInitDialog() { CFont m_Font; VERIFY(m_Font.CreateFont( 12, // nHeight 0, // nWidth 0, // nEscapement 0, // nOrientation FW_NORMAL, // nWeight FALSE, // bItalic FALSE, // bUnderline 0, // cStrikeOut ANSI_CHARSET, // nCharSet OUT_DEFAULT_PRECIS, // nOutPrecision CLIP_DEFAULT_PRECIS, // nClipPrecision DEFAULT_QUALITY, // nQuality DEFAULT_PITCH | FF_SWISS, // nPitchAndFamily "Courier")); // lpszFacename CWnd *pWnd = GetDlgItem(IDC_MESSAGE_TEXT); pWnd->SetFont(&m_Font); m_Font.DeleteObject(); ... } =>Data in Edit text is Bold. When I using mouse to choice this Edit text , it show text wrong. seem, it need control of mouse. for example: show text wrong when type : "y" or "g", it have lost under. i wish you help me. thanks very much. **) when using all character UPPER ==> 1 line don't show 50 character. hope your help. thanks very much regards
nothing
First, m_Font needs to persist - you have declared it on stack, therefore it will be destroyed when OnInitDialog() exits. Make it a class variable. Second, if all you're trying to do is limit the text to 50 characters, you can use pWnd->SetLimitText(50) on the edit box. No need to change the font.
Best wishes, Hans
-
First, m_Font needs to persist - you have declared it on stack, therefore it will be destroyed when OnInitDialog() exits. Make it a class variable. Second, if all you're trying to do is limit the text to 50 characters, you can use pWnd->SetLimitText(50) on the edit box. No need to change the font.
Best wishes, Hans
Hans Dietrich wrote:
First, m_Font needs to persist
Not necessarily, I have been using this for years (usually in OnInitDialog):
CFont f1;
LOGFONT lf1;
::ZeroMemory(&lf1, sizeof(lf1));
lf1.lfHeight = 14;
lf1.lfCharSet = ANSI_CHARSET;
lf1.lfWeight = FW_BOLD;
::lstrcpy(lf1.lfFaceName, "Verdana");
f1.CreateFontIndirect(&lf1);
GetDlgItem(IDC_STATUS)->SetFont(&f1);
f1.Detach();modified on Monday, October 5, 2009 1:06 PM
-
Hans Dietrich wrote:
First, m_Font needs to persist
Not necessarily, I have been using this for years (usually in OnInitDialog):
CFont f1;
LOGFONT lf1;
::ZeroMemory(&lf1, sizeof(lf1));
lf1.lfHeight = 14;
lf1.lfCharSet = ANSI_CHARSET;
lf1.lfWeight = FW_BOLD;
::lstrcpy(lf1.lfFaceName, "Verdana");
f1.CreateFontIndirect(&lf1);
GetDlgItem(IDC_STATUS)->SetFont(&f1);
f1.Detach();modified on Monday, October 5, 2009 1:06 PM