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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. change colors of controls

change colors of controls

Scheduled Pinned Locked Moved C / C++ / MFC
questioncareer
6 Posts 5 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.
  • K Offline
    K Offline
    kumar_mk
    wrote on last edited by
    #1

    asked in an interview ---> 1. Can u change the color of menu bar? 2.How can u change the color of the dialog box initially and what is the function used for changing? 3. How can u change the color of a Button and edit box? please specify steps in the above cases, if you have a sample code it would be great!!! thanx in advance kumar_windows

    L G N H 4 Replies Last reply
    0
    • K kumar_mk

      asked in an interview ---> 1. Can u change the color of menu bar? 2.How can u change the color of the dialog box initially and what is the function used for changing? 3. How can u change the color of a Button and edit box? please specify steps in the above cases, if you have a sample code it would be great!!! thanx in advance kumar_windows

      L Offline
      L Offline
      Laxman Auti
      wrote on last edited by
      #2

      kumar_windows wrote:

      2.How can u change the color of the dialog box initially and what is the function used for changing?

      Override the Wnd::OnCtlColor Method

      kumar_windows wrote:

      How can u change the color of a Button and edit box?

      Override the Wnd::OnCtlColor Method For the method one of the parameter is nctlcolor

      CTLCOLOR_BTN Button control
      CTLCOLOR_DLG Dialog box
      CTLCOLOR_EDIT Edit control
      CTLCOLOR_LISTBOX List-box control
      CTLCOLOR_MSGBOX Message box
      CTLCOLOR_SCROLLBAR Scroll-bar control
      CTLCOLOR_STATIC Static control

      Knock out 't' from can't, You can if you think you can :cool:

      N 1 Reply Last reply
      0
      • K kumar_mk

        asked in an interview ---> 1. Can u change the color of menu bar? 2.How can u change the color of the dialog box initially and what is the function used for changing? 3. How can u change the color of a Button and edit box? please specify steps in the above cases, if you have a sample code it would be great!!! thanx in advance kumar_windows

        G Offline
        G Offline
        Ganesh_T
        wrote on last edited by
        #3

        1. Tocahge the color 0f Menu bar : use DrawItem methos 2. Initiallly changing the Color of dialog handle WM_CTLCOLOR message 3. TO change the color of Button and Edit box You ghave to derive the class from CButton and then handle WM_CTLCOLOR Also Visit: http://support.microsoft.com/kb/q132080/ Cheers "Peace of mind through Technology"

        1 Reply Last reply
        0
        • L Laxman Auti

          kumar_windows wrote:

          2.How can u change the color of the dialog box initially and what is the function used for changing?

          Override the Wnd::OnCtlColor Method

          kumar_windows wrote:

          How can u change the color of a Button and edit box?

          Override the Wnd::OnCtlColor Method For the method one of the parameter is nctlcolor

          CTLCOLOR_BTN Button control
          CTLCOLOR_DLG Dialog box
          CTLCOLOR_EDIT Edit control
          CTLCOLOR_LISTBOX List-box control
          CTLCOLOR_MSGBOX Message box
          CTLCOLOR_SCROLLBAR Scroll-bar control
          CTLCOLOR_STATIC Static control

          Knock out 't' from can't, You can if you think you can :cool:

          N Offline
          N Offline
          Nibu babu thomas
          wrote on last edited by
          #4

          A_Laxman wrote:

          CTLCOLOR_BTN Button control

          Doesn't work with a button. You have to ownerdraw.


          Nibu thomas A Developer Programming tips[^]  My site[^]

          1 Reply Last reply
          0
          • K kumar_mk

            asked in an interview ---> 1. Can u change the color of menu bar? 2.How can u change the color of the dialog box initially and what is the function used for changing? 3. How can u change the color of a Button and edit box? please specify steps in the above cases, if you have a sample code it would be great!!! thanx in advance kumar_windows

            N Offline
            N Offline
            Nibu babu thomas
            wrote on last edited by
            #5

            kumar_windows wrote:

            How can u change the color of the dialog box initially and what is the function used for changing?

            You can do one touch setting using...

            SetDialogBkColor
            (
            RGB(255, 0 , 0), //red background
            RGB(0, 255, 0) //green foreground
            );

            From now on any dialog that comes up will be using the background and foreground color you specified. Call from InitInstance method of the application class. This is a member function of CWinApp.


            Nibu thomas A Developer Programming tips[^]  My site[^]

            1 Reply Last reply
            0
            • K kumar_mk

              asked in an interview ---> 1. Can u change the color of menu bar? 2.How can u change the color of the dialog box initially and what is the function used for changing? 3. How can u change the color of a Button and edit box? please specify steps in the above cases, if you have a sample code it would be great!!! thanx in advance kumar_windows

              H Offline
              H Offline
              Hamid Taebi
              wrote on last edited by
              #6

              you can use derived button and use wm_drawitem of course change owner draw in property button for background color like Nibu thomas for initially but you can use WM_PAINT and use handle dc/cedit use WM_CTLCOLOREDIT that in event wParam is handle to device context edit use HDC hdc = (HDC)wParam;_**


              **_

              whitesky


              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