Mike Kitchen wrote:
Hi
You need to use the MouseEventArgs Class. see msdn here
http://msdn.microsoft.com/library/en...WindowsFormsMo useEventArgsClassTopic.asp
Hope this helps
Publicjoe
C# Tutorial at http://www.publicjoe.f9.co.uk/csharp/tut.html
C# Snippets at http://www.publicjoe.f9.co.uk/csharp/snip/snippets.html
"Andreas Müller" <me@privacy.net> wrote in message
news:c6************@ID-83644.news.uni-berlin.de... Hi all,
I need to wait for the user to click the mouse:
// some code before
WaitForMouseClick();// Wait until the user clicks the mouse
// go on doing something
Under Win32 using C++, you could poll the mouse buttons states. Is
this possible using C# and .NET?
Thanks in advance,
Andy
Hi Mike,
thanks for the answer, however that was not what I was looking for :-(. I
propably explained it bad.
The normal way in a win form application to capture the mouse is to react to
the mouse events, such as MouseDown using the MouseEventArgs class .
However, I have the (strange? ;-) ) need to do something like this
class Xox
{
public static AquirePointFromUser()
{
// promt the user
MessageBox.Show("Please pick a point");
// now wait *here* for the pick of the user
WaitForMouseClick();
// get the currrent position
return Control.MousePosition;
}
private static WaitForMouseClick()
{
// see below
}
}
I need this for an API of my application. When a client calls
Xox.AquirePointFromUser(), it has to be made sure, that the user really
clicks and that the client can't go on untill it happened.
The idea of the API function is, that when called, the user is prompted to
select something and after that the function returns. So I want to wait for
the mouse to be clicked. What I mean by waiting, is that WaitForMouseClick()
wil not return *before* the mouse was clicked.
In Pseudo code, WaitForMouseClick() would look like this
private static void WaitForMouseClick()
{
while(true)
{
bool bMouseDown = Poll_Mouse_State_Button();//<-this is what
//
im looking for
if(bMouseDown)
return;
}
}
I can do this in Win32, so I guess it can be don using C#, too.
I hope this explains it a bit better.
Cheers,
Andy