473,381 Members | 1,479 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,381 software developers and data experts.

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 4580
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.comwrote in message
news:11**********************@q2g2000cwa.googlegro ups.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*****@vestryonline.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
For combined you use the &&, for example

if(Mouse.Right && Mouse.LEFT)
//do something
"Chaitanya" <ch**************@gmail.comwrote in message
news:11**********************@q2g2000cwa.googlegro ups.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()

{

InitializeComponent();

}

private void Form1_MouseDown(object sender, MouseEventArgs e)

{

MouseButtons m = e.Button;

switch (m)

{

case MouseButtons.Left:

_mouseLeft = true;

break;

case MouseButtons.Right:

_mouseRight = true;

break;

}

if (_mouseRight && _mouseLeft)

Console.WriteLine("Both buttons are pressed");

Console.WriteLine("Button down " + m.ToString());

}

private void Form1_MouseUp(object sender, MouseEventArgs e)

{

MouseButtons m = e.Button;

switch (m)

{

case MouseButtons.Left:

_mouseLeft = false;

break;

case MouseButtons.Right:

_mouseRight = false;

break;

}

Console.WriteLine("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()

{

InitializeComponent();

}

private void Form1_MouseDown(object sender, MouseEventArgs e)

{

MouseButtons m = e.Button;

switch (m)

{

case MouseButtons.Left:

_mouseLeft = true;

break;

case MouseButtons.Right:

_mouseRight = true;

break;

}

if (_mouseRight && _mouseLeft)

Console.WriteLine("Both buttons are pressed");

Console.WriteLine("Button down " + m.ToString());

}

private void Form1_MouseUp(object sender, MouseEventArgs e)

{

MouseButtons m = e.Button;

switch (m)

{

case MouseButtons.Left:

_mouseLeft = false;

break;

case MouseButtons.Right:

_mouseRight = false;

break;

}

Console.WriteLine("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.Button & (int)MouseButtons.Left) 0)
{
Console.WriteLine("Left");
}
else
{
Console.WriteLine(".");
}

Console.WriteLine(((int)e.Button).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.Right = 2097152, MouseButtons.Left = 1048576. When you add
them, you get your number.

You can combine values yourself:
MouseButtons.Right | MouseButtons.Left

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
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...
44
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...
7
by: the_grove_man | last post by:
How do I invoke a "Right-Click" Programmtically? John
3
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...
2
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...
4
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...
12
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: ...
0
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
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....
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.