Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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)

  • Moderators
Posted

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


Visit...Bassic Software
  • *Experts*
Posted (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 by mutant

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...