Mike said:
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