Determining Mouse Possition

  • Thread starter Thread starter Smoke
  • Start date Start date
S

Smoke

What i want to do, is, in the Activate Event of my form, determine which is the mouse possition, or, maybe even easy, just determine
if the mouse is over my form.
I need to do two differents things on that event, based on if the mouse is over the form or not..

Any help?

Thanks.
 
Hi,

Dim pt As Point = Cursor.Position

will return the postion in screen coordinates.



Ken
 
Smoke,
Have you looked at Control.MousePosition, Control.MouseButtons &
Control.ModifierKeys all shared properties.

Remember that Control.MousePosition is in Screen Coordinates, so you need to
use Control.PointToClient to convert into client coordinates, then you can
use Control.ClientRectangle.Contains to see if the point is on the
ClientArea.

You can use Control.Bounds if you want to include the Non-client area of the
form.

Remember that Form inherits from Control, so the above properties are valid
for Forms also.

Hope this helps
Jay

Smoke said:
What i want to do, is, in the Activate Event of my form, determine which
is the mouse possition, or, maybe even easy, just determine
 
* "Smoke said:
What i want to do, is, in the Activate Event of my form, determine which is the mouse possition, or, maybe even easy, just determine
if the mouse is over my form.

\\\
If Me.Bounds.Contains(Cursor.Position) Then
...
End If
///
 
Thanks, your explanation was very usefull

Jay B. Harlow said:
Smoke,
Have you looked at Control.MousePosition, Control.MouseButtons &
Control.ModifierKeys all shared properties.

Remember that Control.MousePosition is in Screen Coordinates, so you need to
use Control.PointToClient to convert into client coordinates, then you can
use Control.ClientRectangle.Contains to see if the point is on the
ClientArea.

You can use Control.Bounds if you want to include the Non-client area of the
form.

Remember that Form inherits from Control, so the above properties are valid
for Forms also.

Hope this helps
Jay


is the mouse possition, or, maybe even easy, just determine
 
Back
Top