From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

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
(3,691 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
(3,688 Views)

Capture.PNG

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
Message 3 of 4
(3,678 Views)

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

0 Kudos
Message 4 of 4
(3,665 Views)