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

How to change background color of dialog box..

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
9 Posts 4 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
    Shah Satish
    wrote on last edited by
    #1

    Hi !!! I have created one dialog box ( picture control).I want to change background color of my dialog box. I did some steps but there is no change..I dont know may be some where i did mistake.. My steps are :- In the Header file of my Dialog(ga_dwgpv.h),added a CBrush variable ( member variable ). Assuming that i have declared it as such.

    CBrush m_brush;

    In the OnInitDialog function of my dialog, added this code to create the brush.

    m_brush.CreateSolidBrush(RGB(150,50,100));

    Handle the WM_CTLCOLOR message in my dialog box and in the OnCtlColor function, added this code.

    m_brush.CreateSolidBrush(RGB(150,50,100));

    Is this correct ?? There is no error in programme. Any other method to change backgroung color ?? Thanking you Shah

    T J H 3 Replies Last reply
    0
    • S Shah Satish

      Hi !!! I have created one dialog box ( picture control).I want to change background color of my dialog box. I did some steps but there is no change..I dont know may be some where i did mistake.. My steps are :- In the Header file of my Dialog(ga_dwgpv.h),added a CBrush variable ( member variable ). Assuming that i have declared it as such.

      CBrush m_brush;

      In the OnInitDialog function of my dialog, added this code to create the brush.

      m_brush.CreateSolidBrush(RGB(150,50,100));

      Handle the WM_CTLCOLOR message in my dialog box and in the OnCtlColor function, added this code.

      m_brush.CreateSolidBrush(RGB(150,50,100));

      Is this correct ?? There is no error in programme. Any other method to change backgroung color ?? Thanking you Shah

      T Offline
      T Offline
      toxcct
      wrote on last edited by
      #2

      show the whole function. i suspect you to call the base class' function, or not to return the context


      [VisualCalc][Flags Beginner's Guide] | [Forums Guidelines][My Best Advice]

      S 1 Reply Last reply
      0
      • S Shah Satish

        Hi !!! I have created one dialog box ( picture control).I want to change background color of my dialog box. I did some steps but there is no change..I dont know may be some where i did mistake.. My steps are :- In the Header file of my Dialog(ga_dwgpv.h),added a CBrush variable ( member variable ). Assuming that i have declared it as such.

        CBrush m_brush;

        In the OnInitDialog function of my dialog, added this code to create the brush.

        m_brush.CreateSolidBrush(RGB(150,50,100));

        Handle the WM_CTLCOLOR message in my dialog box and in the OnCtlColor function, added this code.

        m_brush.CreateSolidBrush(RGB(150,50,100));

        Is this correct ?? There is no error in programme. Any other method to change backgroung color ?? Thanking you Shah

        J Offline
        J Offline
        jhwurmbach
        wrote on last edited by
        #3

        Shah Satish wrote:

        I want to change background color of my dialog box.

        You seem to almost have it. just return m_brush from the function. Maybe this[^] can help you?


        "We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation." -- Caius Petronius, Roman Consul, 66 A.D.

        S 1 Reply Last reply
        0
        • T toxcct

          show the whole function. i suspect you to call the base class' function, or not to return the context


          [VisualCalc][Flags Beginner's Guide] | [Forums Guidelines][My Best Advice]

          S Offline
          S Offline
          Shah Satish
          wrote on last edited by
          #4

          Yeh..This is working now..But problem is This is showing color for whole dialog box but i want to change backgroung color of my Picture control box only.. what should i do ? Shah

          1 Reply Last reply
          0
          • J jhwurmbach

            Shah Satish wrote:

            I want to change background color of my dialog box.

            You seem to almost have it. just return m_brush from the function. Maybe this[^] can help you?


            "We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation." -- Caius Petronius, Roman Consul, 66 A.D.

            S Offline
            S Offline
            Shah Satish
            wrote on last edited by
            #5

            Thanks for reply..I want to change color of small box which is reside in my dialog box ( Picture control )..ITs showing me whole dialog box back groung color (not Small box ( picture control). Any suggestion..How to change Backgroung color of Picture control box ? Shah

            J 1 Reply Last reply
            0
            • S Shah Satish

              Thanks for reply..I want to change color of small box which is reside in my dialog box ( Picture control )..ITs showing me whole dialog box back groung color (not Small box ( picture control). Any suggestion..How to change Backgroung color of Picture control box ? Shah

              J Offline
              J Offline
              jhwurmbach
              wrote on last edited by
              #6

              H

              Shah Satish wrote:

              How to change Backgroung color of Picture control box ?

              So, you want to have a picture-control on the dialog, which displays the background color of the dialog? The same color the dialog is alredy showing? Odd! :~ What is the picture control to begin with? A CBitmapButton? Well your PictureControl probably wants a bitmap, wo create one with the background color brush and set it as bitmap in the control.


              "We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation." -- Caius Petronius, Roman Consul, 66 A.D.

              S 1 Reply Last reply
              0
              • J jhwurmbach

                H

                Shah Satish wrote:

                How to change Backgroung color of Picture control box ?

                So, you want to have a picture-control on the dialog, which displays the background color of the dialog? The same color the dialog is alredy showing? Odd! :~ What is the picture control to begin with? A CBitmapButton? Well your PictureControl probably wants a bitmap, wo create one with the background color brush and set it as bitmap in the control.


                "We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation." -- Caius Petronius, Roman Consul, 66 A.D.

                S Offline
                S Offline
                Shah Satish
                wrote on last edited by
                #7

                Yeh..In my dialog box,There are two small box..One is text control and second one is Picture control..Picture control box is showing preview of my Autocad file(dwg file)..Here Backgroing color is White and Color of the drawing is black.. I changed by your method but here its changinf color of whole dialog box but not Picture control box. Shah

                J 1 Reply Last reply
                0
                • S Shah Satish

                  Yeh..In my dialog box,There are two small box..One is text control and second one is Picture control..Picture control box is showing preview of my Autocad file(dwg file)..Here Backgroing color is White and Color of the drawing is black.. I changed by your method but here its changinf color of whole dialog box but not Picture control box. Shah

                  J Offline
                  J Offline
                  jhwurmbach
                  wrote on last edited by
                  #8

                  Shah Satish wrote:

                  Picture control box is showing preview of my Autocad file(dwg file).

                  Who, I mean what code, is rendering the dwg-file? Most probably this code has a setting to set the background-color of its rendering? You can also subclass the control and in the derived class handle WM_ERASEBKGND. There you use the background-colored brush to erase the background.


                  "We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation." -- Caius Petronius, Roman Consul, 66 A.D.

                  1 Reply Last reply
                  0
                  • S Shah Satish

                    Hi !!! I have created one dialog box ( picture control).I want to change background color of my dialog box. I did some steps but there is no change..I dont know may be some where i did mistake.. My steps are :- In the Header file of my Dialog(ga_dwgpv.h),added a CBrush variable ( member variable ). Assuming that i have declared it as such.

                    CBrush m_brush;

                    In the OnInitDialog function of my dialog, added this code to create the brush.

                    m_brush.CreateSolidBrush(RGB(150,50,100));

                    Handle the WM_CTLCOLOR message in my dialog box and in the OnCtlColor function, added this code.

                    m_brush.CreateSolidBrush(RGB(150,50,100));

                    Is this correct ?? There is no error in programme. Any other method to change backgroung color ?? Thanking you Shah

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

                    You can use of

                    pDC->SetTextColor( m_clrText ); //set color of text
                    pDC->SetBkColor( m_clrBkgnd ); // set color text background
                    return m_brBackground; // set background

                    On the WM_CTLCOLOR


                    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