Jump to content

Change icon of single VI/Window


Recommended Posts

Just a 'hack' idea: make the window it's own exe with the icon1, then call this exe from the main (icon2).

Felix

No i'm not really looking for a hack, I just want change the icon of one dialog window.

Here's the code I currently have which doesn't work:

post-2399-084613500 1283104717_thumb.png

It seems like the LoadImage works properly, but when I run it I can see that alt-tab the default labview icon is removed but not replace by the icon I want., but I cannot get it back.

SetWindowIcon.vi (LabVIEW 2009), you should be able to run the code wit any bitmap file.

Ton

Link to comment

BTW. No problems changing the icon back again?

No, the WM_Seticon returns a handle with the old icon.

You can drop this VI:

SetWindowIcon.vi

To set or Reset the icon of a front panel vi!

Here's some little demo code:

post-2399-017263700 1283158440_thumb.png

That sets and resets the icon of a FP window.

Note that if you don't reset the icon it will be in memory until the FP window is closed.

Can anybody tell me how the code runs on:

LabVIEW 32 on Windows64-bit

LabVIEW 64 on Windows64-bit

EDIT: Fixed VI to manage multiple windows

Ton

Link to comment

No, the WM_Seticon returns a handle with the old icon.

You can drop this VI:

To set or Reset the icon of a front panel vi!

Here's some little demo code:

post-2399-017263700 1283158440_thumb.png

That sets and resets the icon of a FP window.

Note that if you don't reset the icon it will be in memory until the FP window is closed.

Can anybody tell me how the code runs on:

LabVIEW 32 on Windows64-bit

LabVIEW 64 on Windows64-bit

Ton

Works fine on both x64 an x32 using Win7 and Vista ( once I'd replaced all the ogk stuff :ph34r: )

Link to comment

Yes that definitly works!

Thanks for correcting me.

Now comes the bonus question:

Mac

Linux

Can't really help you with that (well I could theoretically but don't have enough time currently to spend on these things). But if you want to go multiplatform you definitely want to write external code in form of a shared library. Maintaining such platform specific code in the diagram is a major pita. So I guess DLL/shared library it is going to be :shifty:.

Also additional bonus points/troubles for making the that code NOT depend on platform specific icon resources :cool:.

Link to comment
  • 12 years later...

Oooold thread, but maybe someone will answer.

I'd like to change the icon but NOT from an .ico file, i'd prefer to have a LabView image constant.

I tried to find some .net to create an image from an array instead of "from file" but I got lost and cannot find anything when selecting on LV .net constructor....

 

Link to comment

The problem with this idea, is that the ico file contains multiple images in it, at different resolutions.  You could in theory, take the LabVIEW image constant, save it to a temporary PNG file, then use that path to set the icon.  But I think you'd be better off with an ico file itself.  You can embed the ico file in the VI as a string constant, and do the same thing, saving it to a temporary location as well.

Link to comment
31 minutes ago, hooovahh said:

The problem with this idea, is that the ico file contains multiple images in it, at different resolutions.  You could in theory, take the LabVIEW image constant, save it to a temporary PNG file, then use that path to set the icon.  But I think you'd be better off with an ico file itself.  You can embed the ico file in the VI as a string constant, and do the same thing, saving it to a temporary location as well.

You can create an icon on-the-fly using CreateIconIndirect. I have never found the need but, in theory, you could convert an image into the bitmap masks required for an icon. You could then use the WM_SetIcon as previously.

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.