Jump to content

Replacing a control (.ctl) at run-time


vivante

Recommended Posts

Hi guys,
 
I have would like to replace a button in my panels according to user choice. My idea is to create two skins for my application and I have found that to provide a nice user experience I have to customize LV buttons. I've saved two .ctl files into two libraries. Controls have the same name. I tryed to replace the first packed library with the second one, before launching the exe, but button on front panel doesn't reflect the change. Have you any idea? is it feasible?
Link to comment

For this to work you will need a full LabVIEW development environment.  The LabVIEW Run-Time engine does not have the features needed to edit or resave a VI and that is what would be needed.  This means this feature cannot work in a EXE.  So if you have a full LabVIEW install you could do this using LabVIEW scripting.  Go to Tools >> Options then VI Server page and check Show VI Scripting functions.  This will add scripting tools to your palette.  With scripting you can programatically open a VI and replace the control with the one you want and resave it, then run it.

 

I believe packed libraries are made to act as a step between source code and an EXE, where you have the VIs but they don't have block diagrams or front panels.  I know there are options to remove these or leave them but I don't know the default.  If your VI has no block diagram then you can't edit it and resave.  So for this to work you will need LabVIEW development, scripting, and VIs that can be edited.

Link to comment
Thank you guys,
I think that changing the image attached as "decal" is enough in my case. Usually,  I customize buttons and I was wondering if it possible to do it programmatically in an executable file (without scripting). I have seen that it's possible to import multiple images from clipboard as "decal" when I customize a button. Is it possible to switch between imported images, programmatically (using a "decal index" or similar)?
Link to comment

I didn't realize this conversation had the scope limited to a button, and more so limited to the decal.  This changes things slightly.  Controls do not have multiple decals and a selection for an index (but sounds like an idea for the exchange maybe)

 

One option is to use a Picture Ring.  This contains multiple images and you can choose which to display.  Instead of having a value change be triggered when the user clicks, you could capture a mouse down and change the picture ring to show the new image.  A little clunky but it could work.

 

There is a way to programatically replace a decal of a button, without the development environment.  Here is a discussion on it.  https://decibel.ni.com/content/thread/4901?tstart=30  This replaces the PNG images within the control and is not something NI would condone because it is messing with a file, whose structure is not documented, and could change at any time.

 

This works well enough but again the .ctl file can't be inside the EXE.  So you would need a way for the control to be loaded in the EXE from disk, and not from reference, or force the reference to be loaded from outside the EXE first.  But then you will get warnings from the EXE saying control was loaded from a different location.

Link to comment
This works well enough but again the .ctl file can't be inside the EXE.  So you would need a way for the control to be loaded in the EXE from disk, and not from reference, or force the reference to be loaded from outside the EXE first.  But then you will get warnings from the EXE saying control was loaded from a different location.

 

 

Well, from my point of you, it's easier creating multiple .ctl files with customized buttons and load them when necessary. My question is: how can I load a button into a panel, programmatically? usually I add buttons when I edit my panels and I was sure it's not possible to add buttons to a panel at run-time...

Link to comment
  • 5 months later...
LabVIEW only permits adding front panel object when editing. People have worked out alternative methods of changing the user interface such as the above suggestions.

 

Well you could do it like this of course:

http://screencast.com/t/ei04L5zm

 

In that example you can add any LabVIEW UI object to the front panel during run time and link data to those objects. 

  • Like 1
Link to comment
Well you could do it like this of course:

http://screencast.com/t/ei04L5zm

 

In that example you can add any LabVIEW UI object to the front panel during run time and link data to those objects. 

Yeah that's nice and all if only there was source code attached.  This also uses scripting (I'm guessing) and that still means only in development, and not RTE.  I hope you have a way to save and load panels and connections too.

 

Others have done similar style UIs, like something I put together last year  http://lavag.org/topic/17046-multi-panel-interface/  

Link to comment
Yeah that's nice and all if only there was source code attached.  This also uses scripting (I'm guessing) and that still means only in development, and not RTE.  I hope you have a way to save and load panels and connections too.

 

Others have done similar style UIs, like something I put together last year  http://lavag.org/topic/17046-multi-panel-interface/

 

Yes this example uses scripting but it would work also as an .*exe if needed. It would just require some extra work. I made that simple example with LV 2011 for our NIDays (Northern Europe) and I will show it also during during my upcoming NIWeek presentation about Innovative UIs. I will share all the source code after that ;) I still need to polish it little bit and add some more documentation.

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
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.