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. radio button

radio button

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
5 Posts 2 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.
  • V Offline
    V Offline
    viliam
    wrote on last edited by
    #1

    Hi, is there any simple way how to change radio-button,check box and group box TEXT COLOR? OnCtlColor evidently doesn't work :-( Or some class to do it for me? Thanx

    viliam

    M 1 Reply Last reply
    0
    • V viliam

      Hi, is there any simple way how to change radio-button,check box and group box TEXT COLOR? OnCtlColor evidently doesn't work :-( Or some class to do it for me? Thanx

      viliam

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      Try playing around with this...

      ON_MESSAGE(WM_CTLCOLORSTATIC, OnCtlColorStatic)

      ...

      // Just an example - there's stuff in this method you don't need
      // and/or that isn't used

      LRESULT CMyDlg::OnCtlColorStatic( WPARAM wParam, LPARAM lParam)
      {
          LRESULT lRet = Default();

      HDC hDC = (HDC)wParam;
          HWND hWnd = (HWND)lParam;

      ::SetTextColor(hDC, RGB(0x00,0xFF,0xFF));
          //::SetBkColor(hDC, RGB(0xFF,0x00,0x00));
          ::SetBkMode(hDC, TRANSPARENT);

      //return lRet;
          return (LRESULT)::GetStockObject(NULL_BRUSH);
      }

      Don't ask me why WM_CTLCOLORSTATIC is used for radio buttons, check boxes, and group boxes :)  Maybe because their text is static! Mark

      Mark Salsbery Microsoft MVP - Visual C++ :java:

      V 1 Reply Last reply
      0
      • M Mark Salsbery

        Try playing around with this...

        ON_MESSAGE(WM_CTLCOLORSTATIC, OnCtlColorStatic)

        ...

        // Just an example - there's stuff in this method you don't need
        // and/or that isn't used

        LRESULT CMyDlg::OnCtlColorStatic( WPARAM wParam, LPARAM lParam)
        {
            LRESULT lRet = Default();

        HDC hDC = (HDC)wParam;
            HWND hWnd = (HWND)lParam;

        ::SetTextColor(hDC, RGB(0x00,0xFF,0xFF));
            //::SetBkColor(hDC, RGB(0xFF,0x00,0x00));
            ::SetBkMode(hDC, TRANSPARENT);

        //return lRet;
            return (LRESULT)::GetStockObject(NULL_BRUSH);
        }

        Don't ask me why WM_CTLCOLORSTATIC is used for radio buttons, check boxes, and group boxes :)  Maybe because their text is static! Mark

        Mark Salsbery Microsoft MVP - Visual C++ :java:

        V Offline
        V Offline
        viliam
        wrote on last edited by
        #3

        thank you, it pushed me closer. I tried your code - and modified it and try it again: - it works to set backgroung color of all controls like radio, check and so on but only Text controls change text color. Radio-Button control, Check-box control even Group-box controls have still default color. I am getting this messages for them but SetTextColor function seems to have no effect called from there ??

        viliam

        M 1 Reply Last reply
        0
        • V viliam

          thank you, it pushed me closer. I tried your code - and modified it and try it again: - it works to set backgroung color of all controls like radio, check and so on but only Text controls change text color. Radio-Button control, Check-box control even Group-box controls have still default color. I am getting this messages for them but SetTextColor function seems to have no effect called from there ??

          viliam

          M Offline
          M Offline
          Mark Salsbery
          wrote on last edited by
          #4

          It works for me on XP SP2 without the common controls 6.0.0.0 manifest entry (no themes). With the themes, radio buttons work, check boxes and group boxes do not. There's no guarantee any of this will work, especially with buttons.  You have to experiment, and then hope it doesn't change in the future. Owner drawn or custom controls are the only guarantee... Good luck :) Mark

          Mark Salsbery Microsoft MVP - Visual C++ :java:

          V 1 Reply Last reply
          0
          • M Mark Salsbery

            It works for me on XP SP2 without the common controls 6.0.0.0 manifest entry (no themes). With the themes, radio buttons work, check boxes and group boxes do not. There's no guarantee any of this will work, especially with buttons.  You have to experiment, and then hope it doesn't change in the future. Owner drawn or custom controls are the only guarantee... Good luck :) Mark

            Mark Salsbery Microsoft MVP - Visual C++ :java:

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

            clear now, i try to take manifest entry away and everything works fine. Now I wonder if is possible to skip manifest just for some part of program - i dont want to lose messageboxes and this better looking Win XP advantages stuff. Thank you for help and advices

            viliam

            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