还是在OnTimer里刷窗口做动画,闪烁的问题,查旧帖多数都是以DC的双缓冲解决的,
但如果我的动画是以CWnd的MoveWindow来实现StaticText移动,尽管已用InvalidateRect缩小范围和SetTimer间隔调小了,还是比较闪...这个好像不能用DC来解决。
有什么办法呢?
但如果我的动画是以CWnd的MoveWindow来实现StaticText移动,尽管已用InvalidateRect缩小范围和SetTimer间隔调小了,还是比较闪...这个好像不能用DC来解决。
有什么办法呢?
在OnPaint里
CWnd* pshowenstr = GetDlgItem(IDC_SHOWENSTR);
CWnd* pshowchstr = GetDlgItem(IDC_SHOWCHSTR);
CWnd* pshowennum = GetDlgItem(IDC_SHOWENNUM);
CWnd* pshowallen = GetDlgItem(IDC_SHOWALLEN);
CWnd* pshowallch = GetDlgItem(IDC_SHOWALLCH);
CWnd* pshowRcountNum = GetDlgItem(IDC_SHOWRECOUNTNUM); theApp.strENamount.Format("%d",theApp.strEN.GetSize());
theApp.strCHamount.Format("%d",theApp.strCH.GetSize());
theApp.strWordCount.Format("%d",theApp.iuycount); pshowallen->SetWindowText(theApp.strENamount);
pshowallch->SetWindowText(theApp.strCHamount);
pshowRcountNum->SetWindowText(theApp.strWordCount); void CshowKioDlg::OnTimer(UINT_PTR nIDEvent)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
if(nIDEvent == 1)
{
//pshowchstr->MoveWindow加位,退位,求和之类的算法,不多,计算量少,判断也不超5个
CRect showrect;
//这个区域就是动画区域
showrect.SetRect(10,10,600,100);
this->InvalidateRect(showrect);
CDialog::OnTimer(nIDEvent);
}
你的意思是重载?在Dlg.hpublic:
afx_msg void OnTimer(UINT_PTR nIDEvent);
virtual BOOL PreTranslateMessage(MSG* pMsg);
BOOL OnEraseBkgnd(/*CDC* pDC*/);在Dlg.cppBOOL OnEraseBkgnd()
{
return true;
}似乎完全没效果...
取消Invalidate试试
我在OnPaint里完成显示的,所以必须刷新才能出变化...
也试过把MoveWindow挪到OnTimer里完成,效果一样
开个计时器了MoveWindow应该不会造成闪烁,这个很早就见过了。
同时移动两个控件的...
建议一
不要放到OnPaint中
这样管理不太合适
建议二
使用BeginDeferWindowPos,DeferWindowPos,EndDeferWindowPos系列函数
不要用MoveWindow