LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I determine mouse position within a 2D picture control

Solved!
Go to solution

I have an application where I'd like the user to be able to interact with objects drawn in a 2D picture control using the mouse.  In order to do this, I need to translate between screen coordinates, which are passed with the mouse events, and coordinates in the 2D picture control.

 

The problem I'm running into is that I can't find a way to determine the screen coordinate of the upper left hand corner of the 2D picture control's drawing/client area.  I tried using the picture control's "Position" property, but this results in an offset due to the difference between the upper left hand corner of the picture control (including the label, etc.) and the upper-left hand corner of the drawing area.  See attached VI.

 

Does anybody know how to get the screen coordinate of the corner of the picture control's drawing area?

 

Mark Moss

0 Kudos
Message 1 of 4
(4,420 Views)
Solution
Accepted by topic author MarkMoss

I tend to use the Mouse property of the picture control to get the position.  Deals with things like the origin shift for you.

Message 2 of 4
(4,417 Views)

Capture.PNG

aputman
Message 3 of 4
(4,407 Views)

Thanks, the Mouse Position property does exactly what I need.

0 Kudos
Message 4 of 4
(4,394 Views)