?
Solved

Set dialog background colour

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

Thanks.
0
Comment
Question by:shaun341
3 Comments
 
LVL 48

Accepted Solution

by:
AlexFM earned 100 total points
ID: 12572408
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;
}
0
 
LVL 6

Assisted Solution

by:Amritpal Singh
Amritpal Singh earned 100 total points
ID: 12572411
void CMyDialogApp::SetBk(COLORREF txtColor,COLORREF bkColor)
{
    SetDialogBkColor(bkColor,txtColor);
}

and in the main dialog, you call:
((CMyDialogApp*)AfxGetApp())->SetBk(textcolor,bkcolor);

also look at
http://www.codeproject.com/dialog/ProgDlg.asp   and
http://www.kbalertz.com/kb_Q115087.aspx
0
 
LVL 1

Author Comment

by:shaun341
ID: 12574242
Thanks guys
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Suggested Courses

839 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