Matching the Background Color of 3D Graph and Dialog
Measurement Studio>>Measurement Studio for Visual C++
Primary Software Version:
Primary Software Fixed Version:
I want my 3D graph to have the same background color as the dialog box, but when I use the Window Background system color, the colors do not match. How can I make the colors match?
The system colors in Visual C++ are not representative of the actual dialog colors. You can get the background color of the dialog box, but it involves handling the
message, so the code is somewhat difficult. The following steps outline an example solution:
- Declare a CNiColor member in your dialog box (in this example,
cnicolor). You need this member to pass the color from the message handler to the
- Put the following statement in your
mygraph is a variable created from the 3D graph.
- Create a handler for the
WM_CTCOLOR message on your dialog. You create the handler by clicking on the dialog box and bringing up the Messages list. Then find
WM_CTCOLOR and select OnCtlColor from the drop-down list next to it.
- Use the following code for the function:
HBRUSH Ctest2Dlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
color = GetBkColor(pDC->Detach());
cnicolor = CNiColor(color);