Cancel Mouse Down

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Kurt

    Cancel Mouse Down

    I want to restrict a buttons click/doubleclick event to
    firing from the left button only. How do I eliminate the
    middle and right button clicks? I am able to trap these
    but I'm just not sure how to cancel the event....

    thx
  • Armin Zingler

    #2
    Re: Cancel Mouse Down

    "Kurt" <kskaronea@comc ast.net> schrieb[color=blue]
    > I want to restrict a buttons click/doubleclick event to
    > firing from the left button only. How do I eliminate the
    > middle and right button clicks? I am able to trap these
    > but I'm just not sure how to cancel the event....[/color]

    You can not cancel an event, but you can ignore it.


    --
    Armin

    Comment

    • Kurt

      #3
      Re: Cancel Mouse Down

      [color=blue]
      >-----Original Message-----
      >"Kurt" <kskaronea@comc ast.net> schrieb[color=green]
      >> I want to restrict a buttons click/doubleclick event[/color][/color]
      to[color=blue][color=green]
      >> firing from the left button only. How do I eliminate[/color][/color]
      the[color=blue][color=green]
      >> middle and right button clicks? I am able to trap[/color][/color]
      these[color=blue][color=green]
      >> but I'm just not sure how to cancel the event....[/color]
      >
      >You can not cancel an event, but you can ignore it.
      >
      >
      >--
      >Armin
      >
      >.
      >[/color]
      Pardon the terminology... So how do I accomplish this?
      The following allows me to trap the event. What do I
      need to do to have my app ignore it?

      Private Sub Flatbutton3_Mou seDown(ByVal sender As Object,
      ByVal e As System.Windows. Forms.MouseEven tArgs) Handles
      Flatbutton3.Mou seDown

      Dim eventString As String = Nothing
      Select Case e.Button
      Case MouseButtons.Ri ght
      eventString = "R"
      Case MouseButtons.Mi ddle
      eventString = "M"
      End Select
      If eventString = "R" Or eventString = "M" Then

      End If

      End Sub

      Comment

      • Fergus Cooney

        #4
        Re: Cancel Mouse Down

        Hi Kurt,

        You need something along these lines:

        Private MouseButtonDown As MouseButtons

        Sub MouseDown()
        MouseButtonDown = e.Button

        Sub MouseClick() and MouseDblClick()
        If MouseButtonDown <> MouseButtons.Le ft
        Return

        Sub MouseUp()
        MouseButtonDown = MouseButtons.No ne

        Regards,
        Fergus


        Comment

        • Nak

          #5
          Re: Cancel Mouse Down

          Hi Kurt,

          Watch for windows messages, the following shows you how to ignore all
          double clicks to a form except for the left mouse button ones. I hope this
          helps.

          Const WM_RBUTTONDBLCL K = &H206
          Const WM_LBUTTONDBLCL K = &H203
          Const WM_MBUTTONDBLCL K = &H209

          Protected Overrides Sub WndProc(ByRef m As System.Windows. Forms.Message)
          Select Case m.Msg
          Case WM_RBUTTONDBLCL K, WM_MBUTTONDBLCL K : Return
          Case Else
          Call MyBase.WndProc( m)
          End Select
          End Sub

          Private Sub Form1_DoubleCli ck(ByVal sender As Object, ByVal e As
          System.EventArg s) Handles MyBase.DoubleCl ick
          MessageBox.Show ("DOUBLE CLICK!")
          End Sub

          To implement this into a control of your own you just need to override
          the WndProc procedure.

          Nick.

          --
          /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
          "No matter. Whatever the outcome, you are changed."

          Fergus - September 5th 2003
          /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\


          Comment

          • Armin Zingler

            #6
            Re: Cancel Mouse Down

            "Kurt" <kskaronea@comc ast.net> schrieb[color=blue]
            >[color=green]
            > >-----Original Message-----
            > >"Kurt" <kskaronea@comc ast.net> schrieb[color=darkred]
            > >> I want to restrict a buttons click/doubleclick event[/color][/color]
            > to[color=green][color=darkred]
            > >> firing from the left button only. How do I eliminate[/color][/color]
            > the[color=green][color=darkred]
            > >> middle and right button clicks? I am able to trap[/color][/color]
            > these[color=green][color=darkred]
            > >> but I'm just not sure how to cancel the event....[/color]
            > >
            > >You can not cancel an event, but you can ignore it.
            > >
            > >
            > >--
            > >Armin
            > >
            > >.
            > >[/color]
            > Pardon the terminology... So how do I accomplish this?
            > The following allows me to trap the event. What do I
            > need to do to have my app ignore it?
            >
            > Private Sub Flatbutton3_Mou seDown(ByVal sender As Object,
            > ByVal e As System.Windows. Forms.MouseEven tArgs) Handles
            > Flatbutton3.Mou seDown
            >
            > Dim eventString As String = Nothing
            > Select Case e.Button
            > Case MouseButtons.Ri ght
            > eventString = "R"
            > Case MouseButtons.Mi ddle
            > eventString = "M"
            > End Select
            > If eventString = "R" Or eventString = "M" Then
            >
            > End If
            >
            > End Sub[/color]


            Sorry, I don't understand. If you delete the code, you are ignoring the
            event.


            --
            Armin

            Comment

            • Fergus Cooney

              #7
              Re: Cancel Mouse Down

              Hi Armin,

              Kurt doesn't want to ignore MouseDown for Mid and Right buttons, he wants
              to ignore Click and DblClick. These don't provide the button information which
              must therefore be obtained in MouseDown, used in Click and cleared in MouseUp.

              Regards,
              Fergus


              Comment

              • Nak

                #8
                Re: Cancel Mouse Down

                > Kurt doesn't want to ignore MouseDown for Mid and Right buttons, he
                wants[color=blue]
                > to ignore Click and DblClick. These don't provide the button information[/color]
                which[color=blue]
                > must therefore be obtained in MouseDown, used in Click and cleared in[/color]
                MouseUp.

                Hi Fergus,

                Look at my solution :-)

                Nick.

                --
                /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
                "No matter. Whatever the outcome, you are changed."

                Fergus - September 5th 2003
                /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\


                Comment

                • Armin Zingler

                  #9
                  Re: Cancel Mouse Down

                  "Fergus Cooney" <filter-1@tesco.net> schrieb[color=blue]
                  > Kurt doesn't want to ignore MouseDown for Mid and Right buttons,
                  > he wants
                  > to ignore Click and DblClick. These don't provide the button
                  > information which must therefore be obtained in MouseDown, used in
                  > Click and cleared in MouseUp.[/color]

                  Aaaaahhh... now I got it! :-) He wants to distinguish between different
                  mouse buttons in the click event - ok.


                  --
                  Armin

                  Comment

                  • Nak

                    #10
                    Re: Cancel Mouse Down

                    Hmm, maybe I'm imagining things, but I did provide the solution, didn't I?
                    It prevents all double clicks except the left double click from being
                    raised, as requested, oh well :-p

                    Nick.

                    --
                    /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
                    "No matter. Whatever the outcome, you are changed."

                    Fergus - September 5th 2003
                    /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\


                    Comment

                    • Fergus Cooney

                      #11
                      Re: Cancel Mouse Down

                      Hi Nick,

                      Sorry, mate, I got caught up in all sorts. Yes I tested it (couple of
                      syntaxes, no worries) and it works a dream. :-) The only downside for me is
                      the having to hunt around for WM_THISANDTHAT as these don't stay in my brain
                      (lack of use*).

                      I've used my technique ever since I found that VB doesn't provide mouse
                      button info in Click and DblClick. And access to WndProc (what's that) wasn't
                      available then.

                      So now the question is - go with trapping multiple events and passing
                      global mouse button info around (a portable approach) or keep it centralised
                      in WndProc (an API approach). Decisions, decisions. :-)

                      I wonder if Kurt will tell us which one takes his fancy?

                      Regards,
                      Fergus

                      * The constants, not the brain :-)


                      Comment

                      • Nak

                        #12
                        Re: Cancel Mouse Down

                        Hi Fergus,
                        [color=blue]
                        > Sorry, mate, I got caught up in all sorts. Yes I tested it (couple of
                        > syntaxes, no worries) and it works a dream. :-) The only downside for me[/color]
                        is[color=blue]
                        > the having to hunt around for WM_THISANDTHAT as these don't stay in my[/color]
                        brain[color=blue]
                        > (lack of use*).[/color]

                        I see what you mean. Have you tried downloading an API viewer? They come
                        in quite handy sometimes



                        This one is quite compact, and contains all constanst etc..

                        Nick.

                        --
                        /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
                        "No matter. Whatever the outcome, you are changed."

                        Fergus - September 5th 2003
                        /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\


                        Comment

                        • Fergus Cooney

                          #13
                          Re: Cancel Mouse Down

                          Hi Nick,

                          I actually downloaded that very one a few weeks back but it won't work for
                          me. It gives me the language dialogue and then exits when I choose English
                          (the only option). I've emailed the guy (Christoph) but his suggestion
                          (regsvr) didn't work out either. :-(

                          Christoph mentioned having to install it with the VB6 plug-in but I'm not
                          sure what he means. Do you run it within VB6 or standalone?

                          Any ideas?

                          Regards,
                          Fergus


                          Comment

                          • Fergus Cooney

                            #14
                            Re: Cancel Mouse Down

                            Hi Nick,

                            I actually downloaded that very one a few weeks back but it won't work for
                            me. It gives me the language dialogue and then exits when I choose English
                            (the only option). I've emailed the guy (Christoph) but his suggestion
                            (regsvr) didn't work out either. :-(

                            Christoph mentioned having to install it with the VB6 plug-in but I'm not
                            sure what he means. Do you run it within VB6 or standalone?

                            Any ideas?

                            Regards,
                            Fergus

                            ps. This is a resend. The wierdest thing happened. I sent this about four
                            minutes ago. Then went to Inbox and back to the group to force OE to load and
                            show. There was my message and as soon as I clicked it to make it unhighlight,
                            it got struck out and the message "deleted from the server came up". Is VB6 a
                            swear word or something?


                            Comment

                            • Fergus Cooney

                              #15
                              Re: Cancel Mouse Down

                              Hi Nick,

                              I actually downloaded that very one a few weeks back but it won't work for
                              me. It gives me the language dialogue and then exits when I choose English
                              (the only option). I emailed the guy (Christoph) but his suggestion (regsvr)
                              didn't work out either. :-(

                              Christoph mentioned having to install it with the VB6 plug-in but I'm not
                              sure what he means. Do you run it within VB6 or standalone?

                              Any ideas?

                              Regards,
                              Fergus

                              ps. This is a resend. The wierdest thing happened. I sent this about four
                              minutes ago. Then went to Inbox and back to the group to force OE to load and
                              show. There was my message and as soon as I clicked it to make it unhighlight,
                              it got struck out and the message "deleted from the server came up". Is VB6 a
                              swear word or something?

                              pps. This is the second resend. It happened again so I'm trying a bit further
                              to the left.


                              Comment

                              Working...