type text of Edit box using font Courier (VC++6.0) ?
-
hi everybory. i using vc++6.0 and MFC. I want input data text in edit box using font Courier. thanks and wish your help. regards
nothing
CDC *pDC = GetDC(); CFont m_Font; LOGFONT lFont; memset(&lFont, 0, sizeof(lFont)); lFont.lfHeight = MulDiv(20, ::GetDeviceCaps(pDC->m_hDC, LOGPIXELSY), 12 ); lFont.lfWeight = FW_NORMAL; lFont.lfOutPrecision = OUT_TT_ONLY_PRECIS; wcscpy( lFont.lfFaceName, _T("Courier")); // Set the Font m_Font.CreateFontIndirect(&lFont); // Set the specified font for the edit ctrl. m_edit.SetFont(&m_Font);
Величие не Бога может быть недооценена.
-
CDC *pDC = GetDC(); CFont m_Font; LOGFONT lFont; memset(&lFont, 0, sizeof(lFont)); lFont.lfHeight = MulDiv(20, ::GetDeviceCaps(pDC->m_hDC, LOGPIXELSY), 12 ); lFont.lfWeight = FW_NORMAL; lFont.lfOutPrecision = OUT_TT_ONLY_PRECIS; wcscpy( lFont.lfFaceName, _T("Courier")); // Set the Font m_Font.CreateFontIndirect(&lFont); // Set the specified font for the edit ctrl. m_edit.SetFont(&m_Font);
Величие не Бога может быть недооценена.
-
hi u. when i type text for Edit box (for exam id of Text edit box: IDC_TEXT_BOX). font must using is Courier. that is function using where ?
nothing
m_edit in the code is Edit box and if your application is dialog then add that code in InitDialog if SDI, MDI then add in OnInitialUpdate(). And one more thing, use strcpy instead of wcscpy if you have _UNICODE, UNICODE preprocessor. :) Yes, Hope you know that m_edit is of CEditCtrl added using class wizard, once this code is added it will be courier . :)
Величие не Бога может быть недооценена.
-
m_edit in the code is Edit box and if your application is dialog then add that code in InitDialog if SDI, MDI then add in OnInitialUpdate(). And one more thing, use strcpy instead of wcscpy if you have _UNICODE, UNICODE preprocessor. :) Yes, Hope you know that m_edit is of CEditCtrl added using class wizard, once this code is added it will be courier . :)
Величие не Бога может быть недооценена.
hi. I using that is code in function ::OnInitDialog() //---------------- CDC *pDC = GetDC(); CFont m_Font; LOGFONT lFont; memset(&lFont, 0, sizeof(lFont)); lFont.lfHeight = MulDiv(20, ::GetDeviceCaps(pDC-&m_hDC, LOGPIXELSY), 12 ); lFont.lfWeight = FW_NORMAL; lFont.lfOutPrecision = OUT_TT_ONLY_PRECIS; strcpy( lFont.lfFaceName, _T("Courier")); // Set the Font m_Font.CreateFontIndirect(&lFont); // Set the specified font for the edit ctrl. this->SetFont(&m_Font); //----------------------------------------------------------- but it wrong. i wish your help. thanks
nothing
-
hi. I using that is code in function ::OnInitDialog() //---------------- CDC *pDC = GetDC(); CFont m_Font; LOGFONT lFont; memset(&lFont, 0, sizeof(lFont)); lFont.lfHeight = MulDiv(20, ::GetDeviceCaps(pDC-&m_hDC, LOGPIXELSY), 12 ); lFont.lfWeight = FW_NORMAL; lFont.lfOutPrecision = OUT_TT_ONLY_PRECIS; strcpy( lFont.lfFaceName, _T("Courier")); // Set the Font m_Font.CreateFontIndirect(&lFont); // Set the specified font for the edit ctrl. this->SetFont(&m_Font); //----------------------------------------------------------- but it wrong. i wish your help. thanks
nothing
It will not work because
CFont m_Font;
object is declared as local object. 1) MakeCFont m_Font;
object member of your dialog class. 2) Use this code inOnInitDialog()
:// Create the font you need
m_Font.CreateFont(-11, 0, 0, 0, 100, FALSE, FALSE,
0, ANSI_CHARSET, OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
FF_MODERN, "Courier");// Set the specified font for the edit ctrl.
CWnd *pWnd = GetDlgItem(IDC_TEXT_BOX);
pWnd->SetFont(&m_Font);If you need some additional info on CreateFont (the parameters for example) you can find this info here[^]. I hope this helps! :) Regards Nuri Ismail
-
hi. I using that is code in function ::OnInitDialog() //---------------- CDC *pDC = GetDC(); CFont m_Font; LOGFONT lFont; memset(&lFont, 0, sizeof(lFont)); lFont.lfHeight = MulDiv(20, ::GetDeviceCaps(pDC-&m_hDC, LOGPIXELSY), 12 ); lFont.lfWeight = FW_NORMAL; lFont.lfOutPrecision = OUT_TT_ONLY_PRECIS; strcpy( lFont.lfFaceName, _T("Courier")); // Set the Font m_Font.CreateFontIndirect(&lFont); // Set the specified font for the edit ctrl. this->SetFont(&m_Font); //----------------------------------------------------------- but it wrong. i wish your help. thanks
nothing
-
thanks for support of you very much. I hope, in near future, you help for me. thank you very much. regards.
nothing
... ::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. regards
nothing