Hi
i am making a chess game as a project in my OOP course. so the first thing to start with will be to get the coordinates of the form where i click on it. it will help me a lot to start making the movement functions coz i would have the coordinates of the point from where i'll pick up any piece and to the place where i wannna put it.
anyone who knows how to do this please help!
Loading
Matt SpellerPosted Jan 4, 2006, 4:05 AM
The event you need is the mousedown event. It is very simple to set this up. I will show you the code that is needed in case you need it:-
in the constructor/initialise component:-
this.MouseDown+=new MouseEventHandler(Form1_MouseDown);
and the event handler
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
if(e.Button == MouseButtons.Left){
MessageBox.Show(String.Concat(
"Location of mouse when LEFT button is pressed:- ",
e.X, ", ", e.Y));
}
}
Raheel ImtiazPosted Jan 3, 2006, 1:09 PM
AnttiPosted Jan 1, 2006, 5:10 PM