IDC_PICU1 is a picture box in which I draw my bargraph.
Ed wrote:
I have the following code section:
void TestGraph::OnShow()
{
int a, b, c, d;
in = fopen("teststring.dat", "rb");
fread(bars, 30, 1, in);
fclose(in);
CRect cr;
CBrush blk(RGB(0,0,0));
GetDlgItem(IDC_PICU1)->GetClientRect(cr);
CWnd* pWnd=GetDlgItem(IDC_PICU1);
d = (cr.Width()/30);
pControlDC=pWnd->GetDC();
pControlDC->SelectObject(blk);
c=10;
for (b=0; b<30; b++)
{
a = ((bars[b]*10)/14) + 1;
pControlDC->Rectangle (c, cr.Height(), c+2, cr.Height()-a);
c+=d;
}
}
The file teststring.dat contains 30 bytes data in the range of 00 to FF
This routine draws a bargraph of my data in the PICU1 box just fine.
How do I change the color of the bars???
I have tried different values of CBrush with no luck.
Please direct me in the right path.
What control is IDC_PICU1? If its a any of common controls (with the
exception of CButton), you should not paint the color yourself.
Instead let the control take care of the painting. Typically controls
will respond to OnCtlColor and you provide a brush of your choice. It
will then do the painting itself. You should approach it that way.
---
Ajay