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. does OnCtlColor work for buttons?

does OnCtlColor work for buttons?

Scheduled Pinned Locked Moved C / C++ / MFC
question
3 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.
  • Z Offline
    Z Offline
    zoid
    wrote on last edited by
    #1

    Howdy, The OnCtlColor function does not seem to do anything for buttons, and scrollbars. MSDN suggests that by processing the CTLCOLOR_BTN case, the background color for all buttons in a dialog can be set. However when I try this nothing happens. The function behaves correctly for other controls, such as edit and static controls. In the OnCtlColor() function I have: if (nCtlColor == CTLCOLOR_BTN) { pDC->SetBkMode(TRANSPARENT); if(m_buttonBrush) hbr = *m_buttonBrush; } and m_buttonBrush is created earlier. Is it possible to use this function.. I would really like to avoid making my own custom button control and subclassing from it. thanks, Tom

    G 1 Reply Last reply
    0
    • Z zoid

      Howdy, The OnCtlColor function does not seem to do anything for buttons, and scrollbars. MSDN suggests that by processing the CTLCOLOR_BTN case, the background color for all buttons in a dialog can be set. However when I try this nothing happens. The function behaves correctly for other controls, such as edit and static controls. In the OnCtlColor() function I have: if (nCtlColor == CTLCOLOR_BTN) { pDC->SetBkMode(TRANSPARENT); if(m_buttonBrush) hbr = *m_buttonBrush; } and m_buttonBrush is created earlier. Is it possible to use this function.. I would really like to avoid making my own custom button control and subclassing from it. thanks, Tom

      G Offline
      G Offline
      G Steudtel
      wrote on last edited by
      #2

      Hi, I can vaguely remember, that I also tried to use OnCtlColor a century ago. As far as I can remember, the only colour I cold change was the text colour of that button. Regards GSte

      P 1 Reply Last reply
      0
      • G G Steudtel

        Hi, I can vaguely remember, that I also tried to use OnCtlColor a century ago. As far as I can remember, the only colour I cold change was the text colour of that button. Regards GSte

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

        Same here. I could only control the static text, group boxes, and dialog background colors. I just tried again right now and although I do return a brush handle for CTLCOLOR_BTN (and the trace statements I added confirm that), the buttons are drawn using system colors regardless. I ended up creating a color button class (which I wanted to avoid like you) but turned out to be a good thing because I could then make them a bit fancier (e.g. gradient paint).

        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