Jump to content

Programmatically changing image within control


vugie

Recommended Posts

Posted (edited)

Cross-post

I found the way how to change image on boolean button without using control editor. Essentially you have to to manually insert a png as button image and then replace it with another png programmatically inside .ctl file. The only condition is that initial png file has to have greater filesize than new one. If you want to make a lot of buttons just create first one using biggest PNG (by file size not dimensions). Technically it should be possible to replace any image inside a control with this method.

As .ctl file looks exactly like macintosh resource fork, it should be also possible to omit the limitation of smaller size, by updating respective offsets within a file, however I failed with first trials (not many).

Example attached - LV8.2

post-7450-125924959571_thumb.png

buttontest.zip

Edited by vugie
  • Like 2
Posted

Ok, I made it with even simpler way and withouth the limitation of size:

post-7450-125936304312_thumb.png

Respective VIs are located in: <LV_DIR>\resource\plugins\NewDialogFiles\ProjectWizards\IDNPA\CloneIDProject\dependencies\ResManager

In this case I'm searching only for PNG's header (well, part of). If there are more PNGs within control you have to search for something more specific.

Rolf, thanks for inspiration...

buttontest2.zip

  • Like 1
Posted

When I feel better, I'll try it.

I got swine flu apparently. :(

Dude, thats nasty! :)

I had the flu (swine?) bad this winter too, it sucks.

Wishing you a speedy recovery from the swine flu - hope you feel better soon!

Posted

Here is small utility VI to create system button with a given image.

François, you have my blessing to include it in your UI Tools and modify as you like (particularly to include hover states)

With proper acknowledgement, it's gonna be a pleasure... thanks again.

  • 2 weeks later...
Posted (edited)

With proper acknowledgement, it's gonna be a pleasure... thanks again.

Hi

I can't find this file "id_save resource binary file.vi" in LV2009.

Is it an old one that is not supported anymore?

Best regards Bjarne

Edited by Bjarne Joergensen
Posted

Hi

I can't find this file "id_save resource binary file.vi" in LV2009.

Is it an old one that is not supported anymore?

Hello Bjarne,

indeed, you can find those in LV8.x folders. If they exist in LV2009. I haven't found them (or they changed name).

Posted

Hello Bjarne,

indeed, you can find those in LV8.x folders. If they exist in LV2009. I haven't found them (or they changed name).

Changed Name and location

C:\Program Files\National Instruments\LabVIEW 2009\vi.lib\Palette API\ResMgr\Save Resource.vi

-Scott

Posted

Changed Name and location

C:\Program Files\National Instruments\LabVIEW 2009\vi.lib\Palette API\ResMgr\Save Resource.vi

-Scott

Thank you.

I found them, but I got this error:

This VI cannot access the referenced item because of library access scope. Items in private scope can be accessed only from the following locations:

1) from inside the owning library or LabVIEW class

2) from inside a library contained by the owning library.

Why is that?

Regards Bjarne

Posted

This VI cannot access the referenced item because of library access scope. Items in private scope can be accessed only from the following locations:

1) from inside the owning library or LabVIEW class

2) from inside a library contained by the owning library.

Why is that?

Because it is part of a library and is marked as a private item. Looks like you'll need to use the one from 8.6.

-Scott

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.