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. get background color

get background color

Scheduled Pinned Locked Moved C / C++ / MFC
questionlearning
4 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.
  • N Offline
    N Offline
    ns
    wrote on last edited by
    #1

    Since i am trying to put text (CDC) on a Cstatic (which looks bluish on my screen) I would like to set the background color of CDC for the TextOut to be the same as the label color. I tried doing the following in the label class but of course its incorrect. HOw do I get the color of the label so I can SetBkColor of the CDC?

    		COLORREF cl = GetBkColor(GetDC());
    

    GetBkColor' : cannot convert parameter 1 from 'class CDC *' to 'struct HDC__ *'

    thanks, sb

    V 1 Reply Last reply
    0
    • N ns

      Since i am trying to put text (CDC) on a Cstatic (which looks bluish on my screen) I would like to set the background color of CDC for the TextOut to be the same as the label color. I tried doing the following in the label class but of course its incorrect. HOw do I get the color of the label so I can SetBkColor of the CDC?

      		COLORREF cl = GetBkColor(GetDC());
      

      GetBkColor' : cannot convert parameter 1 from 'class CDC *' to 'struct HDC__ *'

      thanks, sb

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

      If this does not help:

      COLORREF cl = GetDC()->GetBkColor();
      

      nor

      COLORREF cl = m_cMyLabel.GetDC()->GetBkColor();
      

      then you can try this:

      COLORREF cl = (COLORREF)GetSysColor(COLOR_3DFACE);
      
      M 1 Reply Last reply
      0
      • V Viorel

        If this does not help:

        COLORREF cl = GetDC()->GetBkColor();
        

        nor

        COLORREF cl = m_cMyLabel.GetDC()->GetBkColor();
        

        then you can try this:

        COLORREF cl = (COLORREF)GetSysColor(COLOR_3DFACE);
        
        M Offline
        M Offline
        Michael Dunn
        wrote on last edited by
        #3

        Those calls to GetDC() are bad - you need to release every DC you get.

        --Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ VB > soccer

        V 1 Reply Last reply
        0
        • M Michael Dunn

          Those calls to GetDC() are bad - you need to release every DC you get.

          --Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ VB > soccer

          V Offline
          V Offline
          Viorel
          wrote on last edited by
          #4

          Michael Dunn wrote:

          Those calls to GetDC() are bad - you need to release every DC you get.

          You are right -- explicit releasing should be preferable. Actually MFC is able to release various handles at idle time. Values returned by GetDC and other functions are temporary objects which are stored in a collection. They a released between message processing.

          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