Jump to content

Programmatically changing image within control


vugie

Recommended Posts

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
Link to comment

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
Link to comment
  • 2 weeks later...

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

Link to comment

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

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.