Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Stop double click message from being sent

Stop double click message from being sent

Scheduled Pinned Locked Moved C / C++ / MFC
question
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mathias S
    wrote on last edited by
    #1

    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

    M 1 Reply Last reply
    0
    • M Mathias S

      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

      M Offline
      M Offline
      Marek Grzenkowicz
      wrote on last edited by
      #2

      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

      M 1 Reply Last reply
      0
      • M Marek Grzenkowicz

        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

        M Offline
        M Offline
        Mathias S
        wrote on last edited by
        #3

        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

        A 1 Reply Last reply
        0
        • M Mathias S

          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

          A Offline
          A Offline
          Anthony_Yio
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups