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

How to use setbkcolor() in OnInitDialog()

Posted on 1998-03-23
4
1,789 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
  • 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

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

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…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

840 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