I have a picture control box (a CStatic) in a dialog. When the user presses a button in the dialog I need the onPaint() to draw an image in it. The problem is, The image is drawn at the loading of the dialog. How do I prevent this and call it only at button press.
My onPaint code;
void CStaticGraph::OnPaint()
{
POINT xy[1000];
CPaintDC dc(this); // device context for painting
CRect Recto;
char LocDim[80];
GetWindowRect(&Recto);
CPoint pBottom,pTop,pLeft;
CPoint p[50];
pBottom.SetPoint(0,0);
pTop.SetPoint(0,Recto.Height());
pLeft.SetPoint(Recto.Width(),Recto.Height());
dc.MoveTo(pBottom);
dc.LineTo(pTop);
dc.LineTo(pLeft);
int y[] ={80,120,180,200};
int x=0;
for(int i=0; i<sizeof(y);i++){
p[i].SetPoint(Recto.Height()-x,y[i]);
if(i>0){
dc.MoveTo(p[i-1]);
dc.LineTo(p[i]);
}
x+=50;
}
}
As you can see I'm plotting a graph, I also need to pass data (the y[] values) at button press. I haven't done that yet.
Thanks.