Solved

CDC::SetBkColor

Posted on 1998-03-01
2
971 Views
Last Modified: 2013-11-20
I dont think im using the SetBkColor function properly.  Could anyone help me out with what im doing wrong?
I've got a dialog box.  It's InitInstance creates a modeless dialog box.  Trying to get a device context to the dialog box and change its background color.
Here's a clip of what im doing:
/////////////////////////////////////////////////////////////////////////////
m_cDlg2.Create( IDD_INFO, this );  //Using CDialog::Create
CDC*      pdcWindow = m_cDlg2.GetWindowDC( );
pdcWindow->SetBkColor( COLORREF( 100, 0, 0));
pdcWindow->UpdateColors();
m_cDlg2.ShowWindow(SW_SHOW);
///////////////////Another Attempt//////////////////////////////////////
m_cDlg2.Create( IDD_INFO, this );
CDC      dcWindow = m_cDlg2.GetWindowDC( );
pdcWindow.SetBkColor( RGB( 100, 0, 0));
pdcWindow.UpdateColors();
m_cDlg2.ShowWindow(SW_SHOW);
/////////////////////////////////////////////////////////////////////////////
The main dialog window appears and the Dlg2 window but no color change.
When i call GetBkColor it returns 0xffffff which i guess is the gray.
Also, im not sure in th line
m_cDlg2.Create( IDD_INFO, this );
whether 'this' points to the main dialog box or the Dlg2 dialog box.

Thanks in advance
0
Comment
Question by:bod_1
2 Comments
 
LVL 23

Accepted Solution

by:
chensu earned 50 total points
ID: 1316691
You should call CWinApp::SetDialogBkColor rather than CDC::SetBkColor().

void SetDialogBkColor( COLORREF clrCtlBk = RGB(192, 192, 192), COLORREF clrCtlText = RGB(0, 0, 0) );

0
 

Author Comment

by:bod_1
ID: 1316692
Thanks Chensu,  I'll give that one a go.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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 (https://www.paessler.com/prtg) 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…

914 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

21 Experts available now in Live!

Get 1:1 Help Now