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. Set Text bold in edit control

Set Text bold in edit control

Scheduled Pinned Locked Moved C / C++ / MFC
tutorial
8 Posts 5 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.
  • S Offline
    S Offline
    sireesha_sree
    wrote on last edited by
    #1

    Hiii all, I need to make text bold in a read only edit control .Can u suggest me how to do this Thanks

    V 1 Reply Last reply
    0
    • S sireesha_sree

      Hiii all, I need to make text bold in a read only edit control .Can u suggest me how to do this Thanks

      V Offline
      V Offline
      vibindia
      wrote on last edited by
      #2

      Try this

      CFont font;
      VERIFY(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
      "Arial")); // lpszFacename

      m_cEdit.SetFont(&font); //Object of the Edit Control

      VIBIN "Fool's run away,where angle's fear to tread"

      P S 2 Replies Last reply
      0
      • V vibindia

        Try this

        CFont font;
        VERIFY(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
        "Arial")); // lpszFacename

        m_cEdit.SetFont(&font); //Object of the Edit Control

        VIBIN "Fool's run away,where angle's fear to tread"

        P Offline
        P Offline
        prasad_som
        wrote on last edited by
        #3

        vibindia wrote:

        FW_NORMAL, // nWeight

        You want to say FW_BOLD, isn't it?


        Prasad MS MVP -  VC++

        V 1 Reply Last reply
        0
        • V vibindia

          Try this

          CFont font;
          VERIFY(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
          "Arial")); // lpszFacename

          m_cEdit.SetFont(&font); //Object of the Edit Control

          VIBIN "Fool's run away,where angle's fear to tread"

          S Offline
          S Offline
          sireesha_sree
          wrote on last edited by
          #4

          Thanks for the suggestion..... Here i want to change the font to bold only... other settings remaining the same.to use this i have to set all other parameters for which i donno the previous set values... when i use this size of text .. and all other settings r getting changed... how can i overcome this..

          P 1 Reply Last reply
          0
          • P prasad_som

            vibindia wrote:

            FW_NORMAL, // nWeight

            You want to say FW_BOLD, isn't it?


            Prasad MS MVP -  VC++

            V Offline
            V Offline
            vibindia
            wrote on last edited by
            #5

            ya in nWeight the Boldness has to be given

            Constant Value
            FW_DONTCARE 0
            FW_THIN 100
            FW_EXTRALIGHT 200
            FW_ULTRALIGHT 200
            FW_LIGHT 300
            FW_NORMAL 400
            FW_REGULAR 400
            FW_MEDIUM 500
            FW_SEMIBOLD 600
            FW_DEMIBOLD 600
            FW_BOLD 700
            FW_EXTRABOLD 800
            FW_ULTRABOLD 800
            FW_BLACK 900
            FW_HEAVY 900

            VIBIN "Fool's run away,where angle's fear to tread"

            R 1 Reply Last reply
            0
            • V vibindia

              ya in nWeight the Boldness has to be given

              Constant Value
              FW_DONTCARE 0
              FW_THIN 100
              FW_EXTRALIGHT 200
              FW_ULTRALIGHT 200
              FW_LIGHT 300
              FW_NORMAL 400
              FW_REGULAR 400
              FW_MEDIUM 500
              FW_SEMIBOLD 600
              FW_DEMIBOLD 600
              FW_BOLD 700
              FW_EXTRABOLD 800
              FW_ULTRABOLD 800
              FW_BLACK 900
              FW_HEAVY 900

              VIBIN "Fool's run away,where angle's fear to tread"

              R Offline
              R Offline
              Rajesh R Subramanian
              wrote on last edited by
              #6

              FW_BOLD in place of FW_NORMAL will do. Why would you suggest FW_NORMAL for some who wants to render bold text? :rolleyes:

              found at bash.org [kernx]|.|.|.|.|.|.|.| [kernx]sorry, wrong window [beox33]say me why in the f*ck will you type that in any window

              D 1 Reply Last reply
              0
              • S sireesha_sree

                Thanks for the suggestion..... Here i want to change the font to bold only... other settings remaining the same.to use this i have to set all other parameters for which i donno the previous set values... when i use this size of text .. and all other settings r getting changed... how can i overcome this..

                P Offline
                P Offline
                prasad_som
                wrote on last edited by
                #7

                You can get current font from dialog, and then modify it to bold. Refer follwoing snippet,

                CFont* ptemp = GetFont();
                LOGFONT lf;
                ptemp->GetLogFont(&lf);
                lf.lfWeight = FW_BOLD;
                CFont Temp1;
                Temp1.CreateFontIndirect(&lf);
                SetFont(&Temp1);


                Prasad MS MVP -  VC++

                1 Reply Last reply
                0
                • R Rajesh R Subramanian

                  FW_BOLD in place of FW_NORMAL will do. Why would you suggest FW_NORMAL for some who wants to render bold text? :rolleyes:

                  found at bash.org [kernx]|.|.|.|.|.|.|.| [kernx]sorry, wrong window [beox33]say me why in the f*ck will you type that in any window

                  D Offline
                  D Offline
                  David Crow
                  wrote on last edited by
                  #8

                  brahmma wrote:

                  Why would you suggest FW_NORMAL for some who wants to render bold text?

                  Yet another example of "failing to fully read the question."


                  "A good athlete is the result of a good and worthy opponent." - David Crow

                  "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                  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