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? 8 4593
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?
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?
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
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?
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());
}
}
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());
}
}
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
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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...
|
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...
|
by: the_grove_man |
last post by:
How do I invoke a "Right-Click" Programmtically?
John
|
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...
|
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...
| |
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...
|
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: ...
|
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?
|
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....
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
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...
|
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...
|
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 ...
| |
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...
| |