redss Posted November 30, 2003 Posted November 30, 2003 in VS.NET, how do I find the coordinates of a mousedown event? in VB6, it was provided by the event handler, like so: Private Sub Label1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) But in .NET (C# or VB) I don't know how to find out the coords with the event handler: private void label1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) Quote
Moderators Robby Posted November 30, 2003 Moderators Posted November 30, 2003 You can do something like this... Private Structure POINTAPI Dim X As Integer Dim Y As Integer End Structure 'place the following in the MouseMove event... Dim p As POINTAPI p.X 'this is your X position p.Y 'this is your Y position Quote Visit...Bassic Software
*Experts* mutant Posted November 30, 2003 *Experts* Posted November 30, 2003 (edited) You could use the Cursor class from the Windows.Form namespace, as the event handler doesnt provide the coordinates. The Position property will return a point for you. Then you decide if you want to count where it is on the whole screen or relatively to a control, using the PointToClient method for the latter. [Edit]I made an error, I looked at the wrong event :eek: [/edit] Edited November 30, 2003 by mutant Quote
Administrators PlausiblyDamp Posted November 30, 2003 Administrators Posted November 30, 2003 The second argument (e) contains this information. e.X is the X co-ord e.Y is the Y co-ord. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
*Experts* mutant Posted November 30, 2003 *Experts* Posted November 30, 2003 Ah, I looked at the wrong event. Thanks for the correction PlausiblyDamp. Quote
Moderators Robby Posted November 30, 2003 Moderators Posted November 30, 2003 Oh man that's true, I forgot about the e arg. D'oh! Quote Visit...Bassic Software
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.