Stop double click message from being sent
-
I have inherited my controller from a CListCtrl. But I want to change so the double click message is not sent. I want the OnLButtonDown message to always be sent. Don’t want any double click. From want I understand is I need to remove the CS_DBLCLKS from window class style that is registered. How do I do that ? or should it not be changed since it’s a standard controller.? Should I register and use a new class info? how do I do that from an inherited class ? /Mathias
-
I have inherited my controller from a CListCtrl. But I want to change so the double click message is not sent. I want the OnLButtonDown message to always be sent. Don’t want any double click. From want I understand is I need to remove the CS_DBLCLKS from window class style that is registered. How do I do that ? or should it not be changed since it’s a standard controller.? Should I register and use a new class info? how do I do that from an inherited class ? /Mathias
I'm not sure, if I understood you properly, but I guess that you should do something like this: 1. Run ClassWizard. 2. Go to Message Maps tab. 3. Choose your class (on the left-hand side). 4. Find WM_LBUTTONDBLCLK (on the right-hand side). 5. Hit Add Function and then Edit Code. 6. Remove (e.g. comment out) standard message handler and, if you want to, add your own (e.g. a message box saying that double clicks are disabled).
void CTest::OnLButtonDblClk(UINT nFlags, CPoint point)
{
//default message handler
//CListCtrl::OnLButtonDblClk(nFlags, point);//your own message handler (optional) AfxMessageBox("Double clicks are disabled.");
}
Let me know if this was helpful. "Gods die, when their believers are gone." --from Sandman by Neil Gaiman
-
I'm not sure, if I understood you properly, but I guess that you should do something like this: 1. Run ClassWizard. 2. Go to Message Maps tab. 3. Choose your class (on the left-hand side). 4. Find WM_LBUTTONDBLCLK (on the right-hand side). 5. Hit Add Function and then Edit Code. 6. Remove (e.g. comment out) standard message handler and, if you want to, add your own (e.g. a message box saying that double clicks are disabled).
void CTest::OnLButtonDblClk(UINT nFlags, CPoint point)
{
//default message handler
//CListCtrl::OnLButtonDblClk(nFlags, point);//your own message handler (optional) AfxMessageBox("Double clicks are disabled.");
}
Let me know if this was helpful. "Gods die, when their believers are gone." --from Sandman by Neil Gaiman
No. the Double click event from windows is still sent to the applications. so when i click too fast, I only get 1 respone to OnLButtonDown() insted of 2. the problem is that the window class has the CS_DBLCLKS flag set. and this tell the OS that this windows should recive the double click event. So I need to remove that. AND i just found the solution. after searching the net for some hours. this worked.
BOOL CMyListCtrl::Create( DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID)
{
if( CListCtrl::Create(dwStyle, rect, pParentWnd, nID) )
{
DWORD dwStyle = GetClassLong( GetSafeHwnd(), GCL_STYLE);
SetClassLong( GetSafeHwnd(), GCL_STYLE, (dwStyle ^ CS_DBLCLKS) );
return TRUE;
}
return FALSE;
}/Mathias
-
No. the Double click event from windows is still sent to the applications. so when i click too fast, I only get 1 respone to OnLButtonDown() insted of 2. the problem is that the window class has the CS_DBLCLKS flag set. and this tell the OS that this windows should recive the double click event. So I need to remove that. AND i just found the solution. after searching the net for some hours. this worked.
BOOL CMyListCtrl::Create( DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID)
{
if( CListCtrl::Create(dwStyle, rect, pParentWnd, nID) )
{
DWORD dwStyle = GetClassLong( GetSafeHwnd(), GCL_STYLE);
SetClassLong( GetSafeHwnd(), GCL_STYLE, (dwStyle ^ CS_DBLCLKS) );
return TRUE;
}
return FALSE;
}/Mathias
Try the PreTranslateMesssage event handler. [MODIFIED]I guess you have found your solution and it even far more better. Glad it works out that way and I have learned. [/MODIFIED] Sonork 100.41263:Anthony_Yio