LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Programatically customize a control

Solved!
Go to solution

I am creating several custom buttons with custom images. It is very tedious to select the 6 picture items and import the pictures manually. Is there a way to script/automate this?

0 Kudos
Message 1 of 17
(1,020 Views)

Sorry, no.  The methods/properties of boolean picture items are not exposed.

0 Kudos
Message 2 of 17
(988 Views)

I don't think I ever tried this, but it might be relevant:

 

https://lavag.org/topic/20145-vector-boolean-creator/


___________________
Try to take over the world!
Message 3 of 17
(965 Views)
Solution
Accepted by Basjong53

@Basjong53 wrote:

I am creating several custom buttons with custom images. It is very tedious to select the 6 picture items and import the pictures manually. Is there a way to script/automate this?


The following snippet will take "Template" ctl, then replace 6 buttons and save to modified:

Snippet.png

something like that:

Screenshot 2024-09-17 16.38.53.png

 

Saved for LabVIEW 2018.

By the way — this will work also in Runtime, not only in Dev Environment and applicable to VIs as well, not only for controls. But some undocumented calls are inside, so use it at your own risk. The size of the PNG files must be the same as used in Template. If you have other size, prepare your own Template first!

Message 4 of 17
(954 Views)

Using that as a starting point, I made this polymorphic.

Message 5 of 17
(885 Views)

@Andrey_Dmitriev  ha scritto:

@Basjong53 wrote:

I am creating several custom buttons with custom images. It is very tedious to select the 6 picture items and import the pictures manually. Is there a way to script/automate this?


The following snippet will take "Template" ctl, then replace 6 buttons and save to modified:


Thank you very much! This works great.

 

The Labview DLL seems very powerful for low-level control. Is there any documentation for these functions? Or are they are like secret stuff that we shouldn't access?

0 Kudos
Message 6 of 17
(798 Views)

@Basjong53 wrote:

@Andrey_Dmitriev  ha scritto:

@Basjong53 wrote:

I am creating several custom buttons with custom images. It is very tedious to select the 6 picture items and import the pictures manually. Is there a way to script/automate this?


The following snippet will take "Template" ctl, then replace 6 buttons and save to modified:


Thank you very much! This works great.

 

The Labview DLL seems very powerful for low-level control. Is there any documentation for these functions? Or are they are like secret stuff that we shouldn't access?


No documentation outside of NI beyond what they documented in the External Code Reference Manual in LabVIEW 3.0!

And emphasis is mine. If you should access them or not is your decision but as it is not documented, NI is free to change, rename or remove any of these calls anytime they want without having to inform you and ask for your permission. And that is the main reason they won't document these things. As long as something is not documented it can be changed easily. Once it is documented it is pretty much chiseled in stone and there might be serious efforts needed to keep it working properly when something related has to be changed. Not documenting it means to have a lot of freedom for future changes.

 

So basically when using this: No warranties, no safety line or safety net and use is at your own risk. Do not call NI if your computer blows up after use of this!

Rolf Kalbermatter
My Blog
Message 7 of 17
(791 Views)

@rolfk wrote:

Do not call NI if your computer blows up after use of this!

Rolf, we are both experienced engineers, and obviously the worst case which could happened here is trivial exception. The LabVIEW will be crashed, which could lead to damaged or lost user files, but recovery works pretty well (but not always) that is all. In very worst case we can get BSOD, but nowadays its not so easy to crash OS in such way from user application (was more easy in W2K, WinXP or Win7 era, but Win10/11 are more resistant as long as hardware not touched actively). And in very very worst case the OS will not recover after this, then needs to be restored from backup or reinstalled from the scratch, which is also not a big deal for any software engineer. But computer will not "blow up" at all, anyway probability is very low.

 

But massive controls customization in LabVIEW sometimes is really annoying thing. In my case this snippet was written roughly in 2007 (therefore slightly messed BD). In this time I've got  a very strict requirements for User interface and around 50 such buttons needs to be changed with own icons which I've got from UI designer. And yes, all six states was used (in good UI you will see visual feedback from mouse hover/mouse pressed but not released, etc). So, this small tool saves huge amount of my time, otherwise I need to click import image around 400 times, which was just crazy and terrible on small buttons. In my dream is customization like I can do in C#/WPF based on XAML, but this is not applicable to LabVIEW. Lot of potential for improvement for NI.

0 Kudos
Message 8 of 17
(762 Views)

@Andrey_Dmitriev wrote:

@rolfk wrote:

Do not call NI if your computer blows up after use of this!

Rolf, we are both experienced engineers, and obviously the worst case which could happened here is trivial exception.


This was specifically not addressed at you! 😁

 

And sometimes a bit of a parabole should be allowed. While it is extremely unlikely that a computer blows up like an explosive of course, there are many ways of things blowing up in figurative speech. It could be also that you created this great tool to do a thing, your colleague upgrades to LabVIEW 2031 half an hour before making a presentation to the big boss and suddenly that harmless looking tool you wrote which he uses somewhere in his own application "blows up" with all kinds of error messages because it can't compile or load or simply crashes. That can also be a blow up for sure!

 

Use of undocumented things is always at your own risk, and while I know that you know, many users here only know enough to be dangerous but not enough to know that they can be dangerous. 😁

Rolf Kalbermatter
My Blog
0 Kudos
Message 9 of 17
(730 Views)

@tst wrote:

I don't think I ever tried this, but it might be relevant:

 

https://lavag.org/topic/20145-vector-boolean-creator/


Thanks for the shoutout. Yes under the hood it uses the same LabVIEW functions replacing sections of the control file with a new vector image so it scales better.  I have updated that example since that post to use native 2D picture controls instead of a Windows explorer search, and added the Google Material icons but I didn't want to post it unless I thought it was ready since it is a somewhat large attachment.

0 Kudos
Message 10 of 17
(727 Views)