Jump to content

Two VIs with same code but different behaviour


vivante

Recommended Posts

Hi,
I didn't know how to entitle this topic. I hope this title is not too generic..
 
I have attached two VIs with the same code. Purpose of the code is "calculate the position of the upper left corner of a button, in display coordinates, not panel coordinates".
When I created the code, see CORRECT RESULT.vi, it worked fine. Then I copied the code into other VIs and the calculated result is not correct, see WRONG RESULT.vi (I have highlighted the wrong value with red backgrond)
 
I have checked the VI properties, but I haven't found a specific property that solve the issue.
 
My colleagues discovered this odd behaviour because they placed the function in existing panels (some of them have complex interfaces with mutiple panes and splitters and in some cases it works, in other cases doesn't work.
 
Have you seen something similar in past?

 

 

post-18107-0-89922600-1422088994_thumb.j

 

CORRECT RESULT.vi

WRONG RESULT.vi

Link to comment

Hi Vivante

I can't open your code because i'm always in LV 2011. But i have worked two days ago on same problem.

Perhaps it's about the origine of the front panel (grey cross ) . Each controls positions are calculated from to this origine (and not the top-left corner of front panel).

When you start with new vi , in general the origine and the top-left corner of front panel are similar. But when you copy the contents of vi to another,

you can place it anywhere, and in this case the origine is certainly far from the top-left corner of front panel.

The exact formule to know the good position of one control with the top-left corner of screen  is :

for Top : ( FP: PanelBounds:Top) + (Control: MasterRectangle:Top) - (Pane: Origine: Vertical)  

for Left : ( FP: PanelBounds:Left) + (Control: MasterRectangle:Left) - (Pane: Origine: Horizontal)

 

You can find one very good paper about positions and dimensions here:: https://decibel.ni.com/content/docs/DOC-22385

 

Another things to know is the origine is defined for one pane. In general , you use only one, but sometimes you need to have several panes.

To know the good position, you will need know from which pane your control are.

For that you can use this vi : https://decibel.ni.com/content/docs/DOC-8360

 

Good week-end

  • Like 1
Link to comment
Hi,

the code of both VIs is exactly the same, and button is placed at panel origin, so, error is not due to button position. in addition the code is independent from splitters and panes.

The very strange thing is that both VIs are identical, but they calculate a different  value of Y (i.e. Vertical distance from top of the screen).

I attached the VIs saved for LabVIEW 2011. I also noted that the file sizes are different, but I don't know the reason.

CORRECT RESULT.vi

WRONG RESULT.vi

Link to comment

I've looked at them and it seems really to be some bug or at least undocumented behaviour.

 

The FP of one VI seems to return an offset of 1pproximately 120 pixels in the vertical.  The Panel method "CvtPaneltoScreenCoordinates" suffers from the same problem (but might be an easier method to get what you want as it automatically takes into account the title bar and so on).

 

Ah, I found something interesting:

Click on the bottom right corner of the FP with scrollbars visible and choose Properties.  When you exit you will see that the selection box for the panel is way off.  Could it be that the origin of the pane was changed programatically and some internal state got messed up?

 

Here's the picture

post-3076-0-95812700-1422361780.png

Edited by shoneill
Link to comment

Not sure what's going on, but the problem lies within CvtPaneltoScreenCoordinates. That keeps giving me negative values. I copied the code from the correct VI onto a new Vi and it worked just fine. Copied code from the wrong VI to a new VI and it didn't work. Tried copying CvtPaneltoScreenCoordinates from the good to the bad, but that didn't do anything. Some reference somewhere is getting screwed up or something.

Link to comment

Hi vivante

I have investigate your vi 's and i think it's about the background front panel image . When you right click on  horizontal slider, you see dashed line who are not at same place between two vi's.

I don't know how modify it , but i think his position have effect in  the pane coordinate convertion methode.

This bug is associate with this vi (wrong). If you create copy of Correct vi with "save as" , the copy stay correct.

I wish that help you.

 

Houps Shoneil seem more speed than me.

Edited by Bobillier
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.