Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to use setbkcolor() in OnInitDialog()

Posted on 1998-03-23
4
Medium Priority
?
1,902 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 200 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

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

618 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