Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

SystemColor does not work for Plot area of Graph3D

I would like the plot area color of my Graph3D control to be the same color as background. I tried to use the system color in the property page but it does not work: all system color appear black. I tried to find myself the good color combination but it is not perfect and it changes according to the PC you are working on.
Is it a bug?
Thanks for your help
0 Kudos
Message 1 of 6
(4,268 Views)
It may be easier to set the background color than to try to match it. Just set the color you would like for the plot area color on your Graph3D control and then programatically set the form background to match the control color. The C# code to do it would look something like this:

private void Form1_Load(object sender, System.EventArgs e)
{
this.BackColor = axCWGraph3D1.PlotAreaColor;
}
Message 2 of 6
(4,267 Views)
Thanks you for your answer. What would be the code in C++? I do not use C#.
You think that system colors are definitively not available for plot area?
0 Kudos
Message 3 of 6
(4,268 Views)
The system colors in Visual C++ don't seem to be very representative of the actual colors on the dialog (I tried using them programatically as well as through the properties and they still don't match the background of the dialog). I did figure out how you can match the background of the graph to the background of the dialog, but doing anything with the background color of the dialog requires handling the WM_CTLCOLOR message, so it's kind of hairy.

Basically, what you want to do is this:
1. Declare a CNiColor member in your Dialog (I called it cnicolor for this example). You just need this to pass the color from the message handler to the OnInitDialog function.
2. Put a statement in your OnInitDialog that looks something like:
mygraph.
SetPlotAreaColor(cnicolor);
3. Create a handler for the WM_CTCOLOR message on your dialog (it should create a function called OnCtlColor).
4. Use the following code for the function:

HBRUSH Ctest2Dlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);

COLORREF color;
color = GetBkColor(pDC->Detach());
cnicolor = CNiColor(color);

return hbr;
}

This will make the background of the graph match the background of the Dialog. If you want to do it the other way around, just handle the same message and use pDC->setBkColor(COLORREF). Feel free to post here if you have any questions, or you can call or email Measurement Studio tech support and ask to speak to Ryan.
0 Kudos
Message 4 of 6
(4,267 Views)
Thank you Ryan for your answer, I try this and tell you the result
0 Kudos
Message 5 of 6
(4,266 Views)
I tried it and it works perfectly. Many thanks for your help, it was exactly what I wanted to do,
Bye!
0 Kudos
Message 6 of 6
(4,267 Views)