Solved

How to use setbkcolor() in OnInitDialog()

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
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.

738 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