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. How can change color of dialog box

How can change color of dialog box

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

    Hi All. How can we chnage default color to our own color of a dialog box in MFC Dialog based applications. Thanaking You all Shesahidar Patnam

    _ 1 Reply Last reply
    0
    • S sheshidar

      Hi All. How can we chnage default color to our own color of a dialog box in MFC Dialog based applications. Thanaking You all Shesahidar Patnam

      _ Offline
      _ Offline
      _AnsHUMAN_
      wrote on last edited by
      #2

      sheshidar wrote:

      How can change color of dialog box

      Override WM_CTLCOLOR.

      HBRUSH COnlyForYou::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
      {
       HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
       HBRUSH BkgBrush = ::CreateSolidBrush(RGB(0,0,255));		
          if(GetSafeHwnd()==pWnd->GetSafeHwnd())
              {
      			pDC->SetBkColor(RGB(0,0,255));
      			hbr = BkgBrush;
              }
      
          return hbr;
      }
      

      Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_

      S 1 Reply Last reply
      0
      • _ _AnsHUMAN_

        sheshidar wrote:

        How can change color of dialog box

        Override WM_CTLCOLOR.

        HBRUSH COnlyForYou::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
        {
         HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
         HBRUSH BkgBrush = ::CreateSolidBrush(RGB(0,0,255));		
            if(GetSafeHwnd()==pWnd->GetSafeHwnd())
                {
        			pDC->SetBkColor(RGB(0,0,255));
        			hbr = BkgBrush;
                }
        
            return hbr;
        }
        

        Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_

        S Offline
        S Offline
        sheshidar
        wrote on last edited by
        #3

        Thx very much. but how I have to call this function.

        H _ 2 Replies Last reply
        0
        • S sheshidar

          Thx very much. but how I have to call this function.

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

          You dont need to call this event you need to insert this event to your class

          _**


          **_

          WhiteSky


          S 1 Reply Last reply
          0
          • S sheshidar

            Thx very much. but how I have to call this function.

            _ Offline
            _ Offline
            _AnsHUMAN_
            wrote on last edited by
            #5

            sheshidar wrote:

            how I have to call this function.

            You can use class wizard to add the code for you. The framework calls this member function when a child control is about to be drawn.

            Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_

            1 Reply Last reply
            0
            • H Hamid Taebi

              You dont need to call this event you need to insert this event to your class

              _**


              **_

              WhiteSky


              S Offline
              S Offline
              sheshidar
              wrote on last edited by
              #6

              Thx very Much I got it now,

              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