WM_LBUTTONDBLCLK和WM_LBUTTONDOWN的触发解决方法

由于鼠标双击的WM_LBUTTONDBLCLK伴随WM_LBUTTONDOWN消息的发生,导致鼠标双击事件,总是被之前的WM_LBUTTONDOWN截断,WM_LBUTTONDBLCLK消息触发不了。

 

BOOL   bShouldTrigger   =   TRUE;
void   CTestDlg::OnLButtonDown(UINT   nFlags,   CPoint   point)  
{
if(   nFlags&0x8000   )
AfxMessageBox( "鼠标单击! ");
else
{
bShouldTrigger   =   TRUE;
// UINT   aa   =   GetDoubleClickTime();   //   我的系统是500ms
SetTimer(   109,   200,   0   );
}
CDialog::OnLButtonDown(nFlags,   point);
}
void   CTestDlg::OnLButtonDblClk(UINT   nFlags,   CPoint   point)  
{
bShouldTrigger   =   FALSE;
AfxMessageBox( "鼠标双击! ");
CDialog::OnLButtonDblClk(nFlags,   point);
}

void   CTestDlg::OnTimer(UINT   nIDEvent)  
{
if(   nIDEvent   ==   109   )
{
KillTimer(   109   );
if(   bShouldTrigger   )
PostMessage(   WM_LBUTTONDOWN,   MK_LBUTTON|0x8000   ,   0   );
}
CDialog::OnTimer(nIDEvent);
}

你可能感兴趣的:(WM_LBUTTONDBLCLK和WM_LBUTTONDOWN的触发解决方法)