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. Background color of Dialog

Background color of Dialog

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.
  • A Offline
    A Offline
    act_x
    wrote on last edited by
    #1

    How can I change the background color of a dialog ?

    H K 2 Replies Last reply
    0
    • A act_x

      How can I change the background color of a dialog ?

      H Offline
      H Offline
      Harsha Gopal
      wrote on last edited by
      #2

      You can go to the WM_PAINT (OnPaint()) of the dialog and add the following code CRect rect; CBrush brush(RGB(100, 0, 0)); dc.GetWindow()->GetWindowRect(&rect); ScreenToClient(&rect); dc.FillRect(&rect, &brush); dc is CPaint dc(this); Harsha ---------------------------------- http://www.ece.arizona.edu/~hpg ----------------------------------

      1 Reply Last reply
      0
      • A act_x

        How can I change the background color of a dialog ?

        K Offline
        K Offline
        kochhar
        wrote on last edited by
        #3

        One way is to override OnCtlColor(), as follows: (1) In your message map, add: ON_WM_CTLCOLOR() (2) Then, add the following function to your Dialog class: (replace CMyDialog with whatever is the proper name in your case) HBRUSH CMyDialog::OnCtlColor(CDC *pDC,CWnd *pWnd,UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC,pWnd,nCtlColor); if(nCtlColor == CTLCOLOR_DLG) { // Dialog background color (Blue) hbr = CreateSolidBrush(RGB(0,0,255)); return hbr; } return hbr; } You can use this method to change the color of pretty much any element of your dialog.

        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