Thomas
Thomas

Reputation: 34208

windows form top and mouse move

in my win form application when i will move my mouse from down to upward and after certain time i can not move my mouse more upward because at the top there is title bar. so how could i detect that my mouse touch the top end of the win form when i will move my mouse.

thanks

Upvotes: 0

Views: 776

Answers (1)

Shaun Hamman
Shaun Hamman

Reputation: 2347

To determine whether your mouse is at the top edge of a form, simply compare the mouses location to the forms location.

Point mouseLocation = System.Windows.Forms.Control.MousePosition;
Point formLocation = form1.Location;

if (mouseLocation.Y == formLocation.Y)
{
    System.Console.WriteLine("The mouse is at the top of the form.");
}

If I remember correctly, the position returned by the forms ".Location" method does NOT include the title bar.

Upvotes: 1

Related Questions