473,508 Members | 2,333 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Mouse, is there way of reading mouse button state without relying on event

I have a button with mouse_click event when pushed. However it does not
generates mouse down event.
To fix this I could poll the mouse state every 10mSec and see if the
mouse button remains down or up.
I did a search on internet & MSDN and to my surprise, it seem there is
no simple solution to actually read the flag relating to mouse button
state.

Is there way around this?.

thanks

Feb 7 '06 #1
4 16225
See the Control.MouseButtons property.

--
Patrick Steele
Microsoft .NET MVP
http://weblogs.asp.net/psteele
<ri***@onetel.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
I have a button with mouse_click event when pushed. However it does not
generates mouse down event.
To fix this I could poll the mouse state every 10mSec and see if the
mouse button remains down or up.
I did a search on internet & MSDN and to my surprise, it seem there is
no simple solution to actually read the flag relating to mouse button
state.

Is there way around this?.

Feb 7 '06 #2
Why not use the MouseDown and the MouseUp events?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

<ri***@onetel.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
I have a button with mouse_click event when pushed. However it does not
generates mouse down event.
To fix this I could poll the mouse state every 10mSec and see if the
mouse button remains down or up.
I did a search on internet & MSDN and to my surprise, it seem there is
no simple solution to actually read the flag relating to mouse button
state.

Is there way around this?.

thanks

Feb 7 '06 #3
Nicholas
That would not work because window button-click take prededance over
the mouseup and mouse down. You have button on a form and mouse mouse
pointer and click button this event fired. I insert a bool variable on
both mousedown and mouseup event, but this flag did not change. I not
sure if this is true for mouseup. i have code within the window
button-click event routine that need to monitor the mouse button
state.

I use this button to zoom in and out the X-Y chart, once I click that
button, it zoom once and pause for 500mSec. The routine then check if
the mouse button is still down and repeat the zoom every 150mSec. This
save clicking many time.

Feb 8 '06 #4
I attached the code example, which work okay but it use DoEvent() which
is bad programming practice.

private void XBtnZoomIn_MouseDown(object sender,
System.Windows.Forms.MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
SM.MouseZoomInX(SD.iZChOrder,SD.iWidth/2,120);
Application.DoEvents();
SC.Invalidate();
DateTime nextEvent = DateTime.Now.AddMilliseconds(dInitialDelay);
TimeSpan ts;
m_XIsZoomInDown = true;
while (m_XIsZoomInDown)
{
System.Threading.Thread.Sleep(5);
ts = nextEvent.Subtract(DateTime.Now);
if (ts.TotalMilliseconds <= 0)
{
SM.MouseZoomInX(SD.iZChOrder,SD.iWidth/2,120);
nextEvent = DateTime.Now.AddMilliseconds(dRepeatDelay);
SC.Invalidate();
}
Application.DoEvents();
}
}
}
private void XBtnZoomIn_MouseUp(object sender,
System.Windows.Forms.MouseEventArgs e)
{
m_XIsZoomInDown=false;
}

What I try to do is to moinitor the change of the left mouse button so
I can quit the loop.

Feb 8 '06 #5

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

Similar topics

7
17119
by: Tyron | last post by:
I need to know if the Left Button of the Mouse is clicked in the WM_NCMOUSEMOVE Notification but this Message doesnt contain the Mouse Button States as WM_MOUSEMOVE does. So how can I get them? ...
4
2228
by: Raj Chudasama | last post by:
I have a controls similiar to the windows calculator. (Please press some buttons on your calculator to see what i am talking about) So when u hover over a button it will change the state (it...
2
2849
by: Rudiga | last post by:
Hi, Is there any kind of mouse over type method in C#, that will change the mouse to a different pointer when the mouse is over a picture box. The reason i as is that i am intending to use a...
18
22046
by: eliss.carmine | last post by:
Is it possible to simulate a mouse click in the window I made (it's a Form), but not give it focus? I tried using WinAPI's mouseevent and SendMessage of WM_LBUTTONDOWN/WM_LBUTTONUP as suggested...
5
574
by: Adeel | last post by:
Hi group! I'm trying to learn C# on my own... I'd appreciate it very much if someone can help me out here. I have a basic form without any controls on it... I want to catch mouse clicks (both...
2
5565
by: cefrancke | last post by:
Is there a way to capture all relevant info about the mouse, without using Mouse Up/Down etc. procedures? I'm trying to make a custom function and send it the mouse info on the click event. ...
2
1779
by: mwatcher | last post by:
Hi all, I am using .net 2.0. How can I get the current state of the mouse button (e.g.. Mouse Button Right is pressed). I'm not in a mouse event handler routine. What I wanna do is to check if...
6
9698
by: marss | last post by:
Hi, How can I define in Firefox whether the left mouse button is pressed when I move mouse over a html element? The documentation says that "e.button == 0 for standard 'click', usually left...
2
3115
by: markszlazak | last post by:
In the following script, a control displays (black box) in each table cell once you mouse over the cell. Mouse down on the control to change the mode of the table. Drag the mouse over cells in the...
0
7225
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7123
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...
0
7324
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7382
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...
1
5052
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...
0
4707
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...
0
3193
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...
1
766
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
418
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...

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.