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. Font color in Dialogs

Font color in Dialogs

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialc++comquestion
4 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.
  • R Offline
    R Offline
    Rafael Fernandez Lopez
    wrote on last edited by
    #1

    Hi !! I'm programming in MFC. I want a CStatic label control to have font color at red. I don't know how to do it, because I'm using this code: CFont* my_font = new CFont; my_font->CreateFont(here all the parameters that I need...); but I can't see anything for the color... What can I do ?? I think that I've to do something with CDC or something... but please, if you could show an example... Thanks in advance !! ;)


    Written by: Rafael Fernández López.

    Visit: http://www.maestroprogramador.com

    R R 2 Replies Last reply
    0
    • R Rafael Fernandez Lopez

      Hi !! I'm programming in MFC. I want a CStatic label control to have font color at red. I don't know how to do it, because I'm using this code: CFont* my_font = new CFont; my_font->CreateFont(here all the parameters that I need...); but I can't see anything for the color... What can I do ?? I think that I've to do something with CDC or something... but please, if you could show an example... Thanks in advance !! ;)


      Written by: Rafael Fernández López.

      Visit: http://www.maestroprogramador.com

      R Offline
      R Offline
      ravjak
      wrote on last edited by
      #2

      Yes you have to use CPen pen(..) and then pDC->SelectObject(pen); don't forget to free resorces DeleteObject(pen) because after some time our application my behave in funy way :) Pain is a weakness living the body

      R 1 Reply Last reply
      0
      • R Rafael Fernandez Lopez

        Hi !! I'm programming in MFC. I want a CStatic label control to have font color at red. I don't know how to do it, because I'm using this code: CFont* my_font = new CFont; my_font->CreateFont(here all the parameters that I need...); but I can't see anything for the color... What can I do ?? I think that I've to do something with CDC or something... but please, if you could show an example... Thanks in advance !! ;)


        Written by: Rafael Fernández López.

        Visit: http://www.maestroprogramador.com

        R Offline
        R Offline
        RChin
        wrote on last edited by
        #3

        Rafael Fernández López wrote: but I can't see anything for the color... Thats because the control's font has nothing to do with the colour being displayed. One method that I use is to implement the WM_CTLCOLOR message handler, and set the draw colour (SetTextColor()) for all or individual static control. Or you can use a derived label class like this: CLabel[^].


        I Dream of Absolute Zero

        1 Reply Last reply
        0
        • R ravjak

          Yes you have to use CPen pen(..) and then pDC->SelectObject(pen); don't forget to free resorces DeleteObject(pen) because after some time our application my behave in funy way :) Pain is a weakness living the body

          R Offline
          R Offline
          Roger Allen
          wrote on last edited by
          #4

          CPen is for line drawing. You need to use CDC::SetTextColor(COLORREF) to choose what colour the text gets drawn in. Roger Allen - Sonork 100.10016 Strong Sad: I am sad I am flying Who is your favorite Strong?

          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