Cancel Mouse Down

  • Thread starter Thread starter Kurt
  • Start date Start date
K

Kurt

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
 
Kurt said:
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....

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


You can not cancel an event, but you can ignore it.
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_MouseDown(ByVal sender As Object,
ByVal e As System.Windows.Forms.MouseEventArgs) Handles
Flatbutton3.MouseDown

Dim eventString As String = Nothing
Select Case e.Button
Case MouseButtons.Right
eventString = "R"
Case MouseButtons.Middle
eventString = "M"
End Select
If eventString = "R" Or eventString = "M" Then

End If

End Sub
 
Hi Kurt,

You need something along these lines:

Private MouseButtonDown As MouseButtons

Sub MouseDown()
MouseButtonDown = e.Button

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

Sub MouseUp()
MouseButtonDown = MouseButtons.None

Regards,
Fergus
 
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_RBUTTONDBLCLK = &H206
Const WM_LBUTTONDBLCLK = &H203
Const WM_MBUTTONDBLCLK = &H209

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

Private Sub Form1_DoubleClick(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.DoubleClick
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
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
 
Kurt said:
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_MouseDown(ByVal sender As Object,
ByVal e As System.Windows.Forms.MouseEventArgs) Handles
Flatbutton3.MouseDown

Dim eventString As String = Nothing
Select Case e.Button
Case MouseButtons.Right
eventString = "R"
Case MouseButtons.Middle
eventString = "M"
End Select
If eventString = "R" Or eventString = "M" Then

End If

End Sub


Sorry, I don't understand. If you delete the code, you are ignoring the
event.
 
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
 
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.

Hi Fergus,

Look at my solution :-)

Nick.

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

Fergus - September 5th 2003
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
 
Fergus Cooney said:
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.

Aaaaahhh... now I got it! :-) He wants to distinguish between different
mouse buttons in the click event - ok.
 
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
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
 
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 :-)
 
Hi Fergus,
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 see what you mean. Have you tried downloading an API viewer? They come
in quite handy sometimes

http://www.activevb.de/rubriken/apiviewer/index-apiviewereng.html

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

Nick.

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

Fergus - September 5th 2003
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
 
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
 
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?
 
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.
 
Hi Fergus,
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?

I thought the plug-ins were so that you could use it directly in the IDE
first of all. But after closer inspection I believe them to be just for
copying the declarations, constants etc. into the clipboard for your desired
syntax.

I installed it with all plug-ins installed in the end, even though I only
use VB.NET. I remember having installation problems to start with too
actually, I couldn't actually get the application to appear after launching
it, so I uninstalled and installed again, and when the first selection
appeared I selected VB6 (or whatever it was, I cant quite remember).

The viewer is quite good, with the exception that you cannot search for
constants by their value, nor does it have descriptions and examples on the
API's, like the one at www.allapi.net.

Nick.

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

Fergus - September 5th 2003
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
 
pps. This is the second resend. It happened again so I'm trying a bit
further
to the left.

LOL think Outlook is being it's usual unreliable self :-)

Nick.

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

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

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

http://www.activevb.de/rubriken/apiviewer/index-apiviewereng.html

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

Yep... Nevertheless the .NET support is really poor and most of the
declares etc. must be corrected by hand. If I have more time I will talk
with Christoph (a "coworker" at ActiveVB) about that.
 
Hi Herfried,

|| Nevertheless the .NET support is really poor ...
|| If I have more time I will talk with Christoph ...

Christoph said to me that if <he> had the time he'd do something about it,
or maybe someone else could?

I think he's too busy reading Terry Pratchett. ;-)

Regards,
Fergus
 
I think he's too busy reading Terry Pratchett. ;-)

LOL

Do you read Fergus?

Nick.

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

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