我做了个模拟轨迹的程序,就是一个圆沿一条直线平滑的运动,但现在我的这个圆沿轨迹运动时,闪的很厉害,而且看起来不连贯,我的settimer的值放大,缩小多是一样的!请问我是如何改进?CPen *newPen,*oldPen;
CGdiObject *newBrush,*oldBrush;
newPen=new CPen(PS_SOLID,1,RGB(234,54,34));
oldPen=pDC->SelectObject(newPen);
newBrush=new CBrush(RGB(234,54,34));
oldBrush=pDC->SelectObject(newBrush);
pDC->Ellipse((int)(m_bX-6.5),(int)(m_bY-6.5),(int)(m_bX+6.5),(int)(m_bY+6.5));
delete newPen;
delete newBrush;这段是放在OnDraw(CDC* pDC)函数中if(!m_Tend)
if(m_StartPoint.x-m_LastEndPoint.x<0)
{ m_bX=m_StartPoint.x;
m_border=m_LastEndPoint.x;
m_Tend=1;
}
else
{
m_bX=m_LastEndPoint.x;
m_border=m_StartPoint.x;
m_Tend=1;
}
else if(m_bX<m_border)
{
m_bX+=(5*m_Tend);
m_bY=(int)((float)(m_LastEndPoint.y-m_StartPoint.y)/(float)(m_LastEndPoint.x-m_StartPoint.x)*(m_bX-m_StartPoint.x)+m_StartPoint.y);
}
else
{
m_Tend=0;
}
InvalidateRect(NULL);
这上面是ontimer函数
CGdiObject *newBrush,*oldBrush;
newPen=new CPen(PS_SOLID,1,RGB(234,54,34));
oldPen=pDC->SelectObject(newPen);
newBrush=new CBrush(RGB(234,54,34));
oldBrush=pDC->SelectObject(newBrush);
pDC->Ellipse((int)(m_bX-6.5),(int)(m_bY-6.5),(int)(m_bX+6.5),(int)(m_bY+6.5));
delete newPen;
delete newBrush;这段是放在OnDraw(CDC* pDC)函数中if(!m_Tend)
if(m_StartPoint.x-m_LastEndPoint.x<0)
{ m_bX=m_StartPoint.x;
m_border=m_LastEndPoint.x;
m_Tend=1;
}
else
{
m_bX=m_LastEndPoint.x;
m_border=m_StartPoint.x;
m_Tend=1;
}
else if(m_bX<m_border)
{
m_bX+=(5*m_Tend);
m_bY=(int)((float)(m_LastEndPoint.y-m_StartPoint.y)/(float)(m_LastEndPoint.x-m_StartPoint.x)*(m_bX-m_StartPoint.x)+m_StartPoint.y);
}
else
{
m_Tend=0;
}
InvalidateRect(NULL);
这上面是ontimer函数
解决方案 »
- 用户权限管理的若干表的数据库设计问题
- Socket的一个时间等待问题.
- Access数据库中有“日期/时间”字段,在Debug中加入一条信息就出错!怎么回事呢?
- 关于CTabCtrl的两个消息
- 《VC技术内幕》简单问题请教
- 关于视频捕捉卡的问题
- 什么在Windows终端服务客户端窗口中键盘模拟输入不行?
- 请教这样的功能怎样实现
- MFC怎么实现这种好友列表的效果呀,好友列表上下分行,还有消息显示
- 难道就没人会吗?请高高高高高手赐教!!!!----再问ShellExecute()可不可以在新建窗口中打开IE?
- VS2003下MFC多文档拆分窗口,每个窗口的处理类该如可添加消息响应
- 求救啊,关于First-chance exception in XX.exe (ntdll.dll): 0xC0000005: Access Violation
OnEraseBkgnd返回true
然后OnDraw里用双缓冲