Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mouse position relative to form

Status
Not open for further replies.

pdbowling

Programmer
Mar 28, 2003
267
US
Hello, Everyone.

I have a panel on a form. I am clicking and dragging in the panel. I want to determine if the final mouse position on the form is still on the panel.

I can find the position of the panel on the form:

Code:
NumberPanelLocationX = panel1.Location.X;
NumberPanelLocationY = panel1.Location.Y;
NumberPanelEndLocationX = panel1.Location.X + panel1.Width;
NumberPanelEndLocationY = panel1.Location.Y + panel1.Heigh

When I try to find the mouse position relative to the form, I use:

Code:
FormMouseX = Form1.MousePosition.X;
FormMouseY = Form1.MousePosition.Y;

This is giving me the mouse position relative to my monitor.

How should I find the mouse position relative to the form?

Thank you, Everyone.

Patrick B
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top