admin 管理员组文章数量: 1184232
鼠标在得到左键双击事件时,同时也得到了左键down的消息。在只想处理双击事件而不处理按下事件,有下面的方法。
思路:
在收到单击事件后,不处理单击事件,而是settimer,将单击事件对应的操作放到timer中,如果再收到双击事件,则killtimer,使得单击事件不再执行。
相关参考代码:
void CDlgVideo::OnLButtonDown(UINT nFlags, CPoint point)
{
CDialog::OnLButtonDown(nFlags, point);
KillTimer(TIMER_ID_LBUTTONDOWN);
SetTimer(TIMER_ID_LBUTTONDOWN, GetDoubleClickTime()+1, NULL);
TRACE("[CDlgVideo::OnLButtonDown] %d\n", GetTickCount());
/*
On simple click, kill the previous timer,
if any, and start a new timer with SetTimer. The timeout interval is
the value returned by GetDoubleClickTime plus several microseconds.
Then, in the handler for timer call KillTimer and execute your actions
designed for simple clicks. In the handler for double clicks, call
KillTimer and execute your actions designed for double clicks.
*/
}
//////////
void CDlgVideo::OnTimer(UINT_PTR nIDEvent)
{
if (nIDEvent == TIMER_ID_LBUTTONDOWN)
{
TRACE("[CDlgVideo::OnTimer] %d\n", GetTickCount());
KillTimer(TIMER_ID_LBUTTONDOWN);
CPoint point;
GetCursorPos(&point);
ScreenToClient(&point);
if (m_hAVCPlayer != NULL && avcpIsFullScreen(m_hAVCPlayer))
{
}
else
{
if (AfxGetMainWnd() != NULL)
{
//TRACE("[CDlgVideo::OnLButtonDown] point x %d, y %d\n", point.x, point.y);
ClientToScreen(&point);
AfxGetMainWnd()->ScreenToClient(&point);
::SendMessage(AfxGetMainWnd()->GetSafeHwnd(), WM_LBUTTONDOWN, /*nFlags*/MK_LBUTTON, MAKELPARAM(point.x, point.y));
}
}
}
CDialog::OnTimer(nIDEvent);
}
void CDlgVideo::OnLButtonDblClk(UINT nFlags, CPoint point)
{
KillTimer(TIMER_ID_LBUTTONDOWN);
if (PtInRect(m_rectStaticPlayer, point))
{
if (m_hAVCPlayer != NULL)
{
int nPlayState = avcpGetPlayState(m_hAVCPlayer);
if (nPlayState == 1 || nPlayState == 3)
{
if (avcpIsFullScreen(m_hAVCPlayer))
{
avcpSetFullScreen(m_hAVCPlayer, false);
}
else
{
avcpSetFullScreen(m_hAVCPlayer, true);
}
}
}
}
CDialog::OnLButtonDblClk(nFlags, point);
}
////
如果左键按下可能对应完成拖动的操作,则有以下参考代码
void CDlgVideo::OnMouseMove(UINT nFlags, CPoint point)
{
if (KillTimer(TIMER_ID_LBUTTONDOWN))
{
// left button is down, now move, so do drag move
SetTimer(TIMER_ID_LBUTTONDOWN, 1, NULL);
}
CDialog::OnMouseMove(nFlags, point);
}
版权声明:本文标题:解决VS配置问题:在Adobe Flash Player里轻松搞定双击和单击混乱 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.roclinux.cn/p/1771551168a3545895.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论