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. how to disable double click event on a button.

how to disable double click event on a button.

Scheduled Pinned Locked Moved C / C++ / MFC
tutorial
11 Posts 6 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.
  • D Offline
    D Offline
    Dhiraj kumar Saini
    wrote on last edited by
    #1

    Hello, I want my button to be clicked only once and not twice. What to do. Thanks In Advance. Dhiraj

    C A R S 4 Replies Last reply
    0
    • D Dhiraj kumar Saini

      Hello, I want my button to be clicked only once and not twice. What to do. Thanks In Advance. Dhiraj

      C Offline
      C Offline
      Code o mat
      wrote on last edited by
      #2

      How about disabling the button after the first click?

      D 1 Reply Last reply
      0
      • C Code o mat

        How about disabling the button after the first click?

        D Offline
        D Offline
        Dhiraj kumar Saini
        wrote on last edited by
        #3

        actually what i want is that the user can only fire single click event and not double click. That is my meaning of disabling actually the button is not disabled but double click should not do any thing. It should not change its state.

        C R 2 Replies Last reply
        0
        • D Dhiraj kumar Saini

          actually what i want is that the user can only fire single click event and not double click. That is my meaning of disabling actually the button is not disabled but double click should not do any thing. It should not change its state.

          C Offline
          C Offline
          Code o mat
          wrote on last edited by
          #4

          As far as i know -and please correct me anyone if i am wrong- if the user doubleclicks your button you will get a click event at first. So at the first click you won't be able to know if the user will doubleclick or just singleclick. To be more clear on this, when the user doubleclicks your button, you get 2 command messages from the button and you either want only one of these or if a doubleclick was done you don't want any command messages at all?

          1 Reply Last reply
          0
          • D Dhiraj kumar Saini

            Hello, I want my button to be clicked only once and not twice. What to do. Thanks In Advance. Dhiraj

            A Offline
            A Offline
            Alan Balkany
            wrote on last edited by
            #5

            Just add both a single-click handler and a double-click handler to the button, and do nothing for a double click.

            P 1 Reply Last reply
            0
            • A Alan Balkany

              Just add both a single-click handler and a double-click handler to the button, and do nothing for a double click.

              P Offline
              P Offline
              PJ Arends
              wrote on last edited by
              #6

              or simply call the single-click handler from the double-click handler


              You may be right I may be crazy -- Billy Joel -- Within you lies the power for good - Use it!

              A 1 Reply Last reply
              0
              • P PJ Arends

                or simply call the single-click handler from the double-click handler


                You may be right I may be crazy -- Billy Joel -- Within you lies the power for good - Use it!

                A Offline
                A Offline
                Alan Balkany
                wrote on last edited by
                #7

                He said he wants it to do nothing on a double click.

                P 1 Reply Last reply
                0
                • A Alan Balkany

                  He said he wants it to do nothing on a double click.

                  P Offline
                  P Offline
                  PJ Arends
                  wrote on last edited by
                  #8

                  That is fine if that is what he wants. But I was thinking of the user who will start rapidly clicking the button only to find that every other click does not work as expected.


                  You may be right I may be crazy -- Billy Joel -- Within you lies the power for good - Use it!

                  1 Reply Last reply
                  0
                  • D Dhiraj kumar Saini

                    Hello, I want my button to be clicked only once and not twice. What to do. Thanks In Advance. Dhiraj

                    R Offline
                    R Offline
                    Rajesh Katalkar
                    wrote on last edited by
                    #9

                    you can use Pretranslatemessage method BOOL ::PreTranslateMessage(MSG* pMsg) { switch (pMsg->message) { case WM_LBUTTONDBLCLK: pMsg->message = WM_LBUTTONDOWN; break; } return 0; } or u can map lbuttondblclk and then post a message of WM_LBUTTONDOWN(best for activex button controls)

                    1 Reply Last reply
                    0
                    • D Dhiraj kumar Saini

                      actually what i want is that the user can only fire single click event and not double click. That is my meaning of disabling actually the button is not disabled but double click should not do any thing. It should not change its state.

                      R Offline
                      R Offline
                      Rajesh Katalkar
                      wrote on last edited by
                      #10

                      u can use PreTranslateMessage(MSG* pMsg) like this BOOL [ur class name]::PreTranslateMessage(MSG* pMsg) { switch (pMsg->message) { case WM_LBUTTONDBLCLK: pMsg->message = WM_LBUTTONDOWN; break; } return 0; }

                      1 Reply Last reply
                      0
                      • D Dhiraj kumar Saini

                        Hello, I want my button to be clicked only once and not twice. What to do. Thanks In Advance. Dhiraj

                        S Offline
                        S Offline
                        sdc395
                        wrote on last edited by
                        #11

                        How about simply removing the double click style from the window's class?

                        BOOL YourButtonClass::PreCreateWindow(CREATESTRUCT &cs)
                        {
                        WNDCLASS wndClass = { 0 };

                        GetClassInfo(NULL, cs.lpszClass, &wndClass);

                        wndClass.style &= ~CS_DBLCLKS;
                        wndClass.lpszClassName = _T("BUTTON-DBLCLKS");

                        if (AfxRegisterClass(&wndClass))
                        {
                        cs.lpszClass = wndClass.lpszClassName;
                        }

                        return __super::PreCreateWindow(cs);
                        }

                        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