Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. type text of Edit box using font Courier (VC++6.0) ?

type text of Edit box using font Courier (VC++6.0) ?

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpquestion
8 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    aa_zz
    wrote on last edited by
    #1

    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

    A 1 Reply Last reply
    0
    • A aa_zz

      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

      A Offline
      A Offline
      Adam Roderick J
      wrote on last edited by
      #2

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

      Величие не Бога может быть недооценена.

      A 1 Reply Last reply
      0
      • A Adam Roderick J

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

        Величие не Бога может быть недооценена.

        A Offline
        A Offline
        aa_zz
        wrote on last edited by
        #3

        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

        A 1 Reply Last reply
        0
        • A aa_zz

          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

          A Offline
          A Offline
          Adam Roderick J
          wrote on last edited by
          #4

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

          Величие не Бога может быть недооценена.

          A 1 Reply Last reply
          0
          • A Adam Roderick J

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

            Величие не Бога может быть недооценена.

            A Offline
            A Offline
            aa_zz
            wrote on last edited by
            #5

            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

            N A 2 Replies Last reply
            0
            • A aa_zz

              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

              N Offline
              N Offline
              Nuri Ismail
              wrote on last edited by
              #6

              It will not work because CFont m_Font; object is declared as local object. 1) Make CFont m_Font; object member of your dialog class. 2) Use this code in OnInitDialog():

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

              1 Reply Last reply
              0
              • A aa_zz

                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

                A Offline
                A Offline
                aa_zz
                wrote on last edited by
                #7

                thanks for support of you very much. I hope, in near future, you help for me. thank you very much. regards.

                nothing

                A 1 Reply Last reply
                0
                • A aa_zz

                  thanks for support of you very much. I hope, in near future, you help for me. thank you very much. regards.

                  nothing

                  A Offline
                  A Offline
                  aa_zz
                  wrote on last edited by
                  #8

                  ... ::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

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups