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. problem with dialog background color

problem with dialog background color

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

    i have a dialog with background color when i minimize the dialog and maximize again i am loosing the color of the dialog if i switch to another window and come back to same dialog the color will appear on the dialog again whats the problem i should not loos the color of the dialod when i minni mize and maximize any message handlr i have to handle ?

    N N H N 4 Replies Last reply
    0
    • S sarat

      i have a dialog with background color when i minimize the dialog and maximize again i am loosing the color of the dialog if i switch to another window and come back to same dialog the color will appear on the dialog again whats the problem i should not loos the color of the dialod when i minni mize and maximize any message handlr i have to handle ?

      N Offline
      N Offline
      Naveen
      wrote on last edited by
      #2

      How did you change the background color??

      nave [OpenedFileFinder]

      1 Reply Last reply
      0
      • S sarat

        i have a dialog with background color when i minimize the dialog and maximize again i am loosing the color of the dialog if i switch to another window and come back to same dialog the color will appear on the dialog again whats the problem i should not loos the color of the dialod when i minni mize and maximize any message handlr i have to handle ?

        N Offline
        N Offline
        namaskaaram
        wrote on last edited by
        #3

        Seems like a paint issue. Try overriding the OnEraseBkgnd() function.Write the code to put color on the screen there. Hope this works out for you.(never tried this though...) cheers! PS:do comment or call the CDialog::OnEraseBkgnd( pDC ) first before putting in your paint code

        modified on Tuesday, May 13, 2008 12:39 AM

        N 1 Reply Last reply
        0
        • N namaskaaram

          Seems like a paint issue. Try overriding the OnEraseBkgnd() function.Write the code to put color on the screen there. Hope this works out for you.(never tried this though...) cheers! PS:do comment or call the CDialog::OnEraseBkgnd( pDC ) first before putting in your paint code

          modified on Tuesday, May 13, 2008 12:39 AM

          N Offline
          N Offline
          namaskaaram
          wrote on last edited by
          #4

          do comment or call the CDialog::OnEraseBkgnd( pDC ) first, before putting in your paint code

          1 Reply Last reply
          0
          • S sarat

            i have a dialog with background color when i minimize the dialog and maximize again i am loosing the color of the dialog if i switch to another window and come back to same dialog the color will appear on the dialog again whats the problem i should not loos the color of the dialod when i minni mize and maximize any message handlr i have to handle ?

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

            CAn you show your code?

            1 Reply Last reply
            0
            • S sarat

              i have a dialog with background color when i minimize the dialog and maximize again i am loosing the color of the dialog if i switch to another window and come back to same dialog the color will appear on the dialog again whats the problem i should not loos the color of the dialod when i minni mize and maximize any message handlr i have to handle ?

              N Offline
              N Offline
              Nitheesh George
              wrote on last edited by
              #6

              Hi Handle the WM_CTLCOLORDLG and place your painting code inside the handler. HBRUSH CBkColorDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); // TODO: Change any attributes of the DC here if(nCtlColor == CTLCOLOR_DLG) { hbr = CreateSolidBrush(RGB(2,22,222)); } else if(nCtlColor == CTLCOLOR_STATIC) { pDC->SetBkMode(TRANSPARENT); hbr = CreateSolidBrush(RGB(2,22,222)); } // TODO: Return a different brush if the default is not desired return hbr; } that's it Regargs Nitheesh

              M 1 Reply Last reply
              0
              • N Nitheesh George

                Hi Handle the WM_CTLCOLORDLG and place your painting code inside the handler. HBRUSH CBkColorDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); // TODO: Change any attributes of the DC here if(nCtlColor == CTLCOLOR_DLG) { hbr = CreateSolidBrush(RGB(2,22,222)); } else if(nCtlColor == CTLCOLOR_STATIC) { pDC->SetBkMode(TRANSPARENT); hbr = CreateSolidBrush(RGB(2,22,222)); } // TODO: Return a different brush if the default is not desired return hbr; } that's it Regargs Nitheesh

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

                Serious resource leak there :) Those brushes should be created and destroyed outside of the WM_CTLCOLOR handler! Mark

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

                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