LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Get front panel position of the control strange behavior

Hi,

 

I have a code that returns the front panel coordinates of a control. I use the same code and front panel design (splitter/pane layout) in two separate VIs, but I get two different result in each VI and I cannot find the difference between them. VIs are attached. I have LV2013 f2.

Download All
0 Kudos
Message 1 of 12
(4,241 Views)

It depends on how you have scrolled, thus the position of your program in the frontpanel.

Can not open 2013 so it's just an edutated guess.

---

UnCertified LabVIEW Student
Mistakes are for learning, that's why suggestions are always welcome!
0 Kudos
Message 2 of 12
(4,233 Views)

Same behavior in LV2012 - VIs are attached.

Download All
0 Kudos
Message 3 of 12
(4,227 Views)

Yes, now scroll a bit up and down.

The values will be different.

 

It's a bit of trial and error, to make it work correctly

I attached a dialog window that i made, this one is also using position to control the window size.

Dont forget to who the input array or replace it with a constant, otherwise the input will be 0 and will give an error

---

UnCertified LabVIEW Student
Mistakes are for learning, that's why suggestions are always welcome!
0 Kudos
Message 4 of 12
(4,222 Views)
Hi andrej,
Please check this for better understanding
http://digital.ni.com/public.nsf/allkb/862567530005F09C862565FD004E7265
Thanks
uday
0 Kudos
Message 5 of 12
(4,205 Views)

Thank you both for the answers, however, I think you didn't understand the problem or I wasn't clear enough.

 

I use code that returns the position of a control in coordinates of the front panel (regardless of the pane scrolling, etc.). I have two VIs that are the same (same front panel, same code - I think I didn't overlooked something), but they return two different results. I think that the result should be the same in both VIs?

Please look at the VIs.

 

0 Kudos
Message 6 of 12
(4,197 Views)
"However the origin also persists when you use the scrollbars in the front panel window, so that (0,0) might not always be the correct origin. Use the FP.Origin property to obtain the correct origin."
Source:http://digital.ni.com/public.nsf/allkb/862567530005F09C862565FD004E7265

To Determine the Position of a Control in Screen Coordinates:
http://digital.ni.com/public.nsf/allkb/084B09DCABB66FD586256E21004F6458
Thanks
uday
0 Kudos
Message 7 of 12
(4,189 Views)

This work if you do not use multi pane layout (splitters). This is because the origin property (pane property) returns coordinates relative to the coordinate system of the pane and not front panel.

See attached VI.

0 Kudos
Message 8 of 12
(4,180 Views)

Dear Andrej,

 

you are indeed correct. If you happen to have multiple panels with splitters, the you have to account for the splitter positions as well, assuming they are to the left, or on top of your control. Here's some very simple code written for your example:

Exact multi-pane control position.png

Of course to make it more flexible for any setup, you will need to add some tuning to that (you can programmatically get the right pane instead indexing with Owning property, check splitter Vertical? property to decide which coordinate to add to, check whether to include splitter based on position and other things I've been too lazy to properly code Smiley Happy), but this is the basic idea.

 

Kind regards:

Andrew Valko
National Instruments Hungary
0 Kudos
Message 9 of 12
(4,076 Views)

Thanks Andrew,

I didn't have time to test this until now. I have an additional question, how do you know which splitters to add? Some of them can be below or right to the control and they shouldn't be added.

0 Kudos
Message 10 of 12
(3,536 Views)