Solved

How to use setbkcolor() in OnInitDialog()

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
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.

706 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now