高手快来!!!OnLButtonDown问题;我想问怎么样才可以在鼠标按下时不停做某事,弹起时则停止啊!
void Mybutton::OnLButtonDown(UINT nFlags, CPoint point)
// TODO: Add your message handler code here and/or call default
while(false == mouseflag)
{ if (1==data)
{OnUp();//发对应sphereDlg.h里函数OnUp()消息; }
else if(2==data)
{ OnDown();}
else if(3==data)
{ OnLeft();}
else if (4==data)
{ OnRight();}
else if (5==data)
{ OnAutoscanon() ;}
Sleep(2000);
}
CButton::OnLButtonDown(nFlags, point);
}
void Mybutton::OnLButtonUp(UINT nFlags, CPoint point)
{// TODO: Add your message handler code here and/or call default
mouseflag= true;
UpdateData(true);
switch(data){
case 1:
case 2:
case 3:
case 4:
case 5:OnStop();
break;
}
CButton::OnLButtonUp(nFlags, point);
}
问题如题目,我想问怎么样才可以在鼠标按下时不停做某事,弹起时则停止啊?我现在上面的代码如果没有注释掉while 则鼠标左键按下时他响应相应的消息,但是鼠标弹起的时候他没有响应OnLButtonUp的消息;
可能是由于他们是同一个线程里吧.
各位高手有没有什么比较好的解决方法啊?请教我菜鸟一下.谢谢!