菜鸟小问题

future0723 2002-11-18 10:11:32
如何时事更新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();
}
}实在想不出那里的问题,请高手指点。
...全文
55 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
Hany1979 2002-11-18
  • 打赏
  • 举报
回复
this->RedrawWindow();
//不过可能会产生闪烁
ruihuahan 2002-11-18
  • 打赏
  • 举报
回复
对,缺少 Invalidate();
Phourm 2002-11-18
  • 打赏
  • 举报
回复
// is redrawn when UpdateWindow is called.
Invalidate();

// Update Window to cause View to redraw.
UpdateWindow();
zhangyilan 2002-11-18
  • 打赏
  • 举报
回复
直接在OnTimer中
输出时间即可

15,980

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧