473,769 Members | 4,591 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Enum constant for "Left + Right" click of MouseButton.

Hello, In my Application i want to know when user clicks both the
"Left" and "Right" buttons of the Mouse.
I am getting a number like this "3145728". But the MouseButtons Enum
contains only Left, Right, Middle, None, XButton1 and XButton2.
I am using .NET 1.1 version.

How can i convert "3145728" to MouseButtons Enum? why Mouse Left+Right
click not added to the Enum? Can anyone help me?

Jan 19 '07 #1
8 4633
Where are you getting that number?

Chaitanya wrote:
Hello, In my Application i want to know when user clicks both the
"Left" and "Right" buttons of the Mouse.
I am getting a number like this "3145728". But the MouseButtons Enum
contains only Left, Right, Middle, None, XButton1 and XButton2.
I am using .NET 1.1 version.

How can i convert "3145728" to MouseButtons Enum? why Mouse Left+Right
click not added to the Enum? Can anyone help me?
Jan 19 '07 #2
For combined you use the &&, for example

if(Mouse.Right && Mouse.LEFT)
//do something
"Chaitanya" <ch************ **@gmail.comwro te in message
news:11******** **************@ q2g2000cwa.goog legroups.com...
Hello, In my Application i want to know when user clicks both the
"Left" and "Right" buttons of the Mouse.
I am getting a number like this "3145728". But the MouseButtons Enum
contains only Left, Right, Middle, None, XButton1 and XButton2.
I am using .NET 1.1 version.

How can i convert "3145728" to MouseButtons Enum? why Mouse Left+Right
click not added to the Enum? Can anyone help me?

Jan 19 '07 #3

DeveloperX wrote:
Where are you getting that number?
Press Left and Right buttons of the mouse and then Drag.
On MouseMove event, i checked e.Button.
Its showing e.Button = 3145728

Jan 19 '07 #4
Sorry totally ignore my post, i was thinking of something else.


"Daniel" <Da*****@vestry online.comwrote in message
news:%2******** ********@TK2MSF TNGP02.phx.gbl. ..
For combined you use the &&, for example

if(Mouse.Right && Mouse.LEFT)
//do something
"Chaitanya" <ch************ **@gmail.comwro te in message
news:11******** **************@ q2g2000cwa.goog legroups.com...
>Hello, In my Application i want to know when user clicks both the
"Left" and "Right" buttons of the Mouse.
I am getting a number like this "3145728". But the MouseButtons Enum
contains only Left, Right, Middle, None, XButton1 and XButton2.
I am using .NET 1.1 version.

How can i convert "3145728" to MouseButtons Enum? why Mouse Left+Right
click not added to the Enum? Can anyone help me?


Jan 19 '07 #5
To recover from my earlier error:

This is how you could do it and this does work, check your output tab as you
click:

public partial class Form1 : Form

{

public bool _mouseLeft = false;

public bool _mouseRight = false;

public Form1()

{

InitializeCompo nent();

}

private void Form1_MouseDown (object sender, MouseEventArgs e)

{

MouseButtons m = e.Button;

switch (m)

{

case MouseButtons.Le ft:

_mouseLeft = true;

break;

case MouseButtons.Ri ght:

_mouseRight = true;

break;

}

if (_mouseRight && _mouseLeft)

Console.WriteLi ne("Both buttons are pressed");

Console.WriteLi ne("Button down " + m.ToString());

}

private void Form1_MouseUp(o bject sender, MouseEventArgs e)

{

MouseButtons m = e.Button;

switch (m)

{

case MouseButtons.Le ft:

_mouseLeft = false;

break;

case MouseButtons.Ri ght:

_mouseRight = false;

break;

}

Console.WriteLi ne("Button up " + m.ToString());

}

}

Jan 19 '07 #6
I hope this doesnt post twice, i had a prob first time but this how you
could do it, check your output tab for results as you click:

public partial class Form1 : Form

{

public bool _mouseLeft = false;

public bool _mouseRight = false;

public Form1()

{

InitializeCompo nent();

}

private void Form1_MouseDown (object sender, MouseEventArgs e)

{

MouseButtons m = e.Button;

switch (m)

{

case MouseButtons.Le ft:

_mouseLeft = true;

break;

case MouseButtons.Ri ght:

_mouseRight = true;

break;

}

if (_mouseRight && _mouseLeft)

Console.WriteLi ne("Both buttons are pressed");

Console.WriteLi ne("Button down " + m.ToString());

}

private void Form1_MouseUp(o bject sender, MouseEventArgs e)

{

MouseButtons m = e.Button;

switch (m)

{

case MouseButtons.Le ft:

_mouseLeft = false;

break;

case MouseButtons.Ri ght:

_mouseRight = false;

break;

}

Console.WriteLi ne("Button up " + m.ToString());

}

}
Jan 19 '07 #7
Oh I see, sorry, this works, it will print . unless the left button is
held down regardless of what other buttons are held down at the same
time, the buttons are or'ed together.
if(((int)e.Butt on & (int)MouseButto ns.Left) 0)
{
Console.WriteLi ne("Left");
}
else
{
Console.WriteLi ne(".");
}

Console.WriteLi ne(((int)e.Butt on).ToString()) ; shows that all the
individual buttons are powers of 2.

Chaitanya wrote:
DeveloperX wrote:
Where are you getting that number?

Press Left and Right buttons of the mouse and then Drag.
On MouseMove event, i checked e.Button.
Its showing e.Button = 3145728
Jan 19 '07 #8
Hello, In my Application i want to know when user clicks both the
"Left" and "Right" buttons of the Mouse.
I am getting a number like this "3145728". But the MouseButtons Enum
contains only Left, Right, Middle, None, XButton1 and XButton2.
I am using .NET 1.1 version.

How can i convert "3145728" to MouseButtons Enum? why Mouse Left+Right
click not added to the Enum? Can anyone help me?
MouseButtons.Ri ght = 2097152, MouseButtons.Le ft = 1048576. When you add
them, you get your number.

You can combine values yourself:
MouseButtons.Ri ght | MouseButtons.Le ft

That's what the "This enumeration has a FlagsAttribute attribute that
allows a bitwise combination of its member values" remark is about in
http://msdn2.microsoft.com/en-us/lib...ns(VS.71).aspx
Hans Kesting
Jan 19 '07 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
9455
by: Alex Clark | last post by:
Hi All, I'm sure this must have been asked a million times due to it's usefulness, but are there any sensible solutions for disabling right click (and other services such as Ctrl+P, Browser hotkeys etc) on a Web-Browser control in VB.NET? Despite Googling for ideas on and off for a week now, I only found one solution and this was to implement IMessageFilter on the form and then trap all the incoming messages. Unfortunately, this...
44
9455
by: Viken Karaguesian | last post by:
Hello all, On occasion I want to open hyperlinks (images, etc.) in a new window. In the past, I've used target="_blank" to open the link in a new window. However, using the "target" attribute causes my pages to fail validation (strict doctype). The validator says "There is no attribute 'target'.." So...how do I open a link in a new window, without Javscript, and pass strict validation?
7
10885
by: the_grove_man | last post by:
How do I invoke a "Right-Click" Programmtically? John
3
8763
by: mehdi | last post by:
I have a field that is a memo and I have a report displaying the text in that memo. What I need to know is how to "justify" the text right to left. The reason is in arabic and persian language we write right to left. What I want:
2
1959
by: Reiki Evolution | last post by:
Hi, Hopefully someone can help me here. I am recoding my web site. The original site was just in HTML but I am teaching myself CSS for the new site. My new site consists of three columns: a sidebar floated left, a sidebar floated right, and the 'main content' which has wide margins to accommodate the floated sidebars. I am working on the main content. I want to do something very simple: I have an image floated left, with some text to...
4
30728
by: marcnz | last post by:
Hi, I am working for a company which as a MS SQL backend and Access as front end. We update automatically each access db on the user local machine when a new feature has become available. We have to stay with MDB for several reasons, so please avoid telling me "you have to convert to MDE"... It is not an option. We need to allow our users to have the right-click so they can export the reports to pdf or other format. We need to remove...
12
4499
by: Michael7 | last post by:
Hi Everyone, I've been trying to get two blocks of text to be aligned, one left, one right, on the same line. What I'm trying to mimic is what I did with tables here: http://www.workmenforChrist.org (under the "Site Map" link) I tried floating the blocks with the code: /*Right box on the index page*/
0
1296
by: DR | last post by:
when i build someone's project, and right click a function "goto definition" is disabled. how to reconfigure a .net project to support "goto definition" when i right click on function calls?
2
1734
by: Tom P. | last post by:
I am writting a extended ListView control and I'd like to stop the default behavior when a user right-clciks on a non-label area and then drags causing a "marching ants" selection box to appear. First, what event is this? And second, how do I stop it? I've trapped the OnItemDrag and OnDragEnter events and it's not them (OnDragEnter doesn't even fire). In OnClick I test for right-click and simply return.
0
10051
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9866
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7413
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5310
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3968
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3571
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.