Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

CDC::SetBkColor

Posted on 1998-03-01
2
986 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

809 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