I have a simple little dialog box, with a few edit boxs and a calc button.
(as well as ok & cancel)
I'am using the OnPaint function to draw some lines on the dialog box, based
on the result of a Calculation, when Calc button is pressed I want to move
the lines to graphically show the result.
my code looks a bit like this
BOOL CWizardDlg::OnInitDialog()
{
CDialog::OnInitDialog();
iSkew=0;
return TRUE;
}
void CWizardDlg::OnPaint()
{
// draw lines on dialog based on the value of skew
CPaintDC dc(this); // device context for painting
CPen Pen1,Pen2;
Pen1.CreatePen(PS_SOLID, 2, RGB(0, 0, 0));
Pen2.CreatePen(PS_DASH, 1, RGB(0, 0, 0));
dc.SelectObject(&Pen1);
// Vertical Lines
dc.MoveTo(left,top+iSkew);
dc.LineTo(left,bott+iSkew);
..
..
}
void CWizardDlg::OnCalc()
{
// Do calc
// get result
iSkew=result;
OnPaint();
}
I know OnPaint() is being called a 2nd time, but for some reason its not
actually drawing on the screen.
Can anyone give me a few points, as to what iam doing wrong.
TIA
Tony
"Tony Maher" <TMa...@tommotek.com> wrote in message
news:3ed2e28d$0$31...@echo-01.iinet.net.au...
Invalidate did it..
void CWizardDlg::OnCalc()
{
// Do calc
// get result
iSkew=result;
Invalidate();
}
Thanks Again
Tony
"Jeff Partch" <je...@mvps.org> wrote in message
news:etCzCfAJ...@TK2MSFTNGP11.phx.gbl...
Calling OnPaint yourself is a technique so deeply and fundamentally flawed that it cannot
possibly work. Don't do it. Invalidate the area you want to redraw (in your case, perhaps
the whole dialog, which will produce annoying flashes), and let the WM_PAINT message
materialize on its own. The reason is the CPaintDC expects a clipping region, which is not
set when you call OnPaint yourself, so you may have an empty clipping region, and no
visible painting would take place.
joe
Joseph M. Newcomer [MVP]
email: newc...@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm