I want it as simple as possible.
"Kahlua" <kahlua@right.here> wrote in message
news:zb6jj.7554$6F6.4662@trndny09...
Can anyone show me how to display a bargraph within my mfc app?
Or direct me to the resource to do it.
Lets say I have an unsigned char string of 16bytes of data ranging in
value from 01h to FFh.
I want to display a bargraph with the 16 vertical bars reflecting the
data value.
Height and width of bargraph not important at this time.
Thanks in advance.
I found this simple code that seems to work ok.
Anything wrong with it?
Why should I not use it?
void CBar1Dlg::OnBar()
{
unsigned char bar[10];
int numbars=10;
int a,b,c,d,i;
for (i=0;i<10;i++) //initialize
bargraph values for testing
bar[i]=i*10;
CRect cr;
CBrush grn(RGB(100,255,100));
c=15,b=5; //initialize
positions
GetDlgItem(IDC_PIC)->GetClientRect(cr); //get drawing area of
PIC
CWnd* pWnd=GetDlgItem(IDC_PIC);
pControlDC=pWnd->GetDC();
d = (cr.Width()-20)/numbars;
pControlDC->SelectObject(wht);
//draw
background
pControlDC->Rectangle(0,0,cr.Width(), cr.Height());
pControlDC->SelectObject(grn); //select color
of
bar
for (b=0; b<numkeys; b++)
{
a = bar[b];
pControlDC->Rectangle (c, cr.Height(), c+10, cr.Height()-a);
c+=d;
}
pControlDC->SelectStockObject(BLACK_BRUSH);
}