菜鸟小问题
如何时事更新Dialog base 的界面?
用一下方法为什么不可以?
BOOL CTestDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
SetTimer(1, 1000, NULL);//增加定时器
return TRUE;
}
void CTestDlg::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
UpdateWindow();//更新窗口
CDialog::OnTimer(nIDEvent);
}
void CTestDlg::OnPaint()
{
if (IsIconic())
{
}
else
{
CPaintDC dc(this); // device context for painting
// Center icon in client rectangle
CRect rect;
GetClientRect(&rect);
CString strTime;
CTime cTime1 = CTime::GetCurrentTime();
strTime = cTime1.Format("%H:%M:%S");
dc.TextOut(0, 0, strTime);//希望在界面上实时输出时间,并1秒更新一次 CDialog::OnPaint();
}
}实在想不出那里的问题,请高手指点。