Solved

How to use setbkcolor() in OnInitDialog()

Posted on 1998-03-23
4
1,842 Views
Last Modified: 2009-12-16
How do you change the backcolor of a dialog box using setbkcolor()? I not know how to get the first parameter "hdc" for this function.  Please show me how to implement this in a OnInitDialog() call.
0
Comment
Question by:englm
[X]
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
  • 3
4 Comments
 
LVL 4

Accepted Solution

by:
tflai earned 50 total points
ID: 1183760
GetDC()->SetBkColor(RGB(255,255,255));
0
 
LVL 4

Expert Comment

by:tflai
ID: 1183761
If you really want to change a dialog's background color, write your handler for WM_CTLCOLOR and return the brush you want.

Example:  set your dialog's background to white.
HBRUSH CMyDlg::OnCtlColor(...)
  {
    return (HBRUSH)GetStockObject(WHITE_BRUSH);
  }
0
 

Author Comment

by:englm
ID: 1183762
The HBRUSH example works great, but for future reference -

To use:
GetDC()->SetBkColor(RGB(255,255,255));

Don't I need to first define a pointer to the CDC like:
CDC* pDC = GetDC():

0
 
LVL 4

Expert Comment

by:tflai
ID: 1183763
Yeh, if you want to have several operations on the DC, you should store the DC pointer first.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

728 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