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. Changing text of a static control as BOLD

Changing text of a static control as BOLD

Scheduled Pinned Locked Moved C / C++ / MFC
11 Posts 4 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.
  • N neha agarwal27

    Hi all, I have made a static text box in my application. i want to make the text of that static dialog box as BOLD. I dont want to change the font just want to make it as bold.... How could i do so.... Thanks in advance

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

    Add a control variable to your static control (m_static here) and add a CFont member to your class (myFont here). You could then apply the bold style to the font in your control like this:

    CFont *font = m_static.GetFont();
    LOGFONT lf;
    font->GetLogFont(&lf);
    lf.lfWeight = FW_BOLD;
    myFont.CreateFontIndirect(&lf);
    m_static.SetFont(&myFont);

    Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP

    N 1 Reply Last reply
    0
    • R Rajesh R Subramanian

      Add a control variable to your static control (m_static here) and add a CFont member to your class (myFont here). You could then apply the bold style to the font in your control like this:

      CFont *font = m_static.GetFont();
      LOGFONT lf;
      font->GetLogFont(&lf);
      lf.lfWeight = FW_BOLD;
      myFont.CreateFontIndirect(&lf);
      m_static.SetFont(&myFont);

      Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP

      N Offline
      N Offline
      neha agarwal27
      wrote on last edited by
      #3

      I am unable to get which type of variable is myFont

      C R 3 Replies Last reply
      0
      • N neha agarwal27

        I am unable to get which type of variable is myFont

        C Offline
        C Offline
        CPallini
        wrote on last edited by
        #4

        it's a CFont, I suppose. :)

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
        This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

        R 1 Reply Last reply
        0
        • N neha agarwal27

          I am unable to get which type of variable is myFont

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

          I said it in my previous reply[^] to you:

          Rajesh R Subramanian wrote:

          and add a CFont member to your class (myFont here).

          Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP

          1 Reply Last reply
          0
          • C CPallini

            it's a CFont, I suppose. :)

            If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
            This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

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

            I suppose she's going to declare the font object to be function local. :)

            Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP

            C 1 Reply Last reply
            0
            • R Rajesh R Subramanian

              I suppose she's going to declare the font object to be function local. :)

              Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP

              C Offline
              C Offline
              CPallini
              wrote on last edited by
              #7

              From my (Italian) point of view your most challenging supposition is about OP gender. :-D

              If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
              This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

              R 1 Reply Last reply
              0
              • C CPallini

                From my (Italian) point of view your most challenging supposition is about OP gender. :-D

                If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

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

                Neha = Indian lady name. :)

                Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP

                C 1 Reply Last reply
                0
                • R Rajesh R Subramanian

                  Neha = Indian lady name. :)

                  Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP

                  C Offline
                  C Offline
                  CPallini
                  wrote on last edited by
                  #9

                  I supposed! :laugh:

                  If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                  This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

                  1 Reply Last reply
                  0
                  • N neha agarwal27

                    I am unable to get which type of variable is myFont

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

                    Also, please make sure that you do NOT have that CFont object (myFont) declared in a local function, but instead as a member of your class. This is to prevent the font object from going out of scope prematurely. :)

                    Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP

                    1 Reply Last reply
                    0
                    • N neha agarwal27

                      Hi all, I have made a static text box in my application. i want to make the text of that static dialog box as BOLD. I dont want to change the font just want to make it as bold.... How could i do so.... Thanks in advance

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

                      There's an example in the Extras section of this article.

                      "Love people and use things, not love things and use people." - Unknown

                      "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