Set dialog background colour

Posted on 2004-11-12
Last Modified: 2013-11-20
How can i set the background colour of a dialog to white?

Question by:shaun341
    LVL 48

    Accepted Solution

    To change background color of all dialog in application add the following line to InitInstance:

    SetDialogBkColor(RGB(255, 255, 255));

    To change background color of specific dialog make toe following steps:

    1) Add member
    CBrush m_BkBrush;
    to the dialog class.

    2) Initialize it in OnInitDialog:
    m_BkBrush.CreateSolidBrush(RGB(255, 255, 255));

    3) Add WM_CTLCOLOR message handler to the dialog:

    HBRUSH CTestDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
        HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);

        // TODO: Return a different brush if the default is not desired
        //return hbr;

        return m_BkBrush;
    LVL 6

    Assisted Solution

    by:Amritpal Singh
    void CMyDialogApp::SetBk(COLORREF txtColor,COLORREF bkColor)

    and in the main dialog, you call:

    also look at   and
    LVL 1

    Author Comment

    Thanks guys

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
    Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
    This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    758 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now