Jump to content
Stinus Olsen

Put your LabVIEW in the Tray -- Once and for all

Recommended Posts

Sweet, I'll definitely check it out. I've been interested in this kind of functionality for personal reasons and always wanted to spend time wrapping some VB code with LabVIEW to get the functionality I wanted.

Share this post


Link to post
Share on other sites

Very nice. I've been looking for this functionality also. Thank you for sharing this. Great! :thumbup1:

Mirko

Share this post


Link to post
Share on other sites
License:

Since i made this code in my sparetime, but planned to be using it at work, i've made arrangements with the grand-old-boss and put a BSD License on it..

...and the community thanks you for it! :yes:

Share this post


Link to post
Share on other sites

Your API is great, I just tried using it out and was impressed!

I have some feature requests that I think would make it even better (and these requests depend on the .NET API)"

  1. If the clicked events could specify whether there was a right-mouse vs left-mouse click on a given menu/tray/balloon tip
  2. If the balloon tip clicked event returned the balloon tip text

Thanks for your contribution to the community!

Share this post


Link to post
Share on other sites

Looks Great!

I posted my own solution for this a little while ago:

NI Community: Icon in Windows system tray with LabVIEW

I'd love to hear some opinions comparing the two and offering suggestions. Maybe we can roll the best of each (assuming my solution has something worth keeping :cool:) into one great tool! It's obvious there's demand for this. I know a number of people have used what I posted, and can see the same thing here.

Share this post


Link to post
Share on other sites

I posted my own solution for this a little while ago: NI Community: Icon in Windows system tray with LabVIEW I'd love to hear some opinions comparing the two and offering suggestions.

I used yours on a side project last week, and I have some things I'd like to change/add in that one. (I should note that it was very easy to use and worked flawlessly!)

  1. The "Register LabVIEW User Events" function outputs an event registration refnum, which makes it impossible to register both NotifyIcon events and other user events on the same event handler. (Good ol' LV doesn't allow additional registration of new strict types on an existing event registration wire, and you can only create one dynamic registration terminal on an event structure so you only get to work with one wire.) So I broke out the user event refnum from your "Initial Event Registration" case and made an indicator from it. This lets me drop my own Register For Events node and wire as many types of user events to it as I like.
    eventrefnum.png
  2. As I mentioned on the NI Community page, the Disposed event doesn't fire the way I expect. Your proposed solution is to modify the order of things in the "Destroy" VI to call Dispose, then unregister the events, Of course, I'd rather handle event reg/unreg myself as explained in #1, so the real solution may be to have "Destroy" call Dispose, then exit, relying on the client to unregister events himself.
  3. The menu for my application had a subset of selections that were mutually exclusive, so they basically had to act like a menu ring. I made a little FGV that wraps your API to provide that behavior for any subset of MenuItems. I've attached it in case you think it should be added to the API.
  4. Using the name of the library to namespace the VIs is ghetto. :P Why not add them to an lvlib? There are few enough that load times and memory bloat won't be an issue.
  5. I'd like to see this packaged as a VIP or OGP, instead of an unversioned ZIP file. I could help you get started with that, if you like. :)
  6. Finally, I'd like to see that whatever blend of these two solutions we come up with is distributed on LAVAG with the BSD license, instead of NI Community with NI's very restrictive T&C.

All told, this is a great LV interface to some nice .NET functionality, and I'd love to see more things like it out in the world!

NotifyIcon Ring.vi

NotifyIcon Ring Action.ctl

  • Like 2

Share this post


Link to post
Share on other sites

That looks really sweet, I am now trying to think of a good excuse to use a tray icon in our project +1 from me

cheers

Dannyt

Share this post


Link to post
Share on other sites

Your API is great, I just tried using it out and was impressed!

I have some feature requests that I think would make it even better (and these requests depend on the .NET API)"

  1. If the clicked events could specify whether there was a right-mouse vs left-mouse click on a given menu/tray/balloon tip
  2. If the balloon tip clicked event returned the balloon tip text

Thanks for your contribution to the community!

Those are really good suggestions!

I actually already did some of the mouse-button stuff as an update to the existing version, and now that I'm not the only one missing this feature I'll probably get around to finish it! :lol:

At the same time I should probably also try putting this in a nice OpenG package as mentioned by Stobber..

Looks Great!

I posted my own solution for this a little while ago:

NI Community: Icon in Windows system tray with LabVIEW

I'd love to hear some opinions comparing the two and offering suggestions. Maybe we can roll the best of each (assuming my solution has something worth keeping :cool:) into one great tool! It's obvious there's demand for this. I know a number of people have used what I posted, and can see the same thing here.

Looks pretty interesting!..I'll definitely have a look at this tonight :yes:

Share this post


Link to post
Share on other sites

Hi

Use this in my new project now. So happy :yes::thumbup1:

I would like to ask how you convert a image(jpeg, png, gif....) to the binary string? I have search but I didn't find a solution.

Thanks in advance.

Bjarne

Share this post


Link to post
Share on other sites

Hi Bjarne

Whenever I find myself in need of a new tray icon, I usually do a search on Iconarchive or Google using descriptive terms for the pictures I have in mind.

I then download the images or icon files I find interresting, or just the ones I think looks cool :D

If the file is an icon file I use an icon editor to remove icons bigger then 32x32px in the file (I stick with IcoFX v1.6.4 - mainly because its simple and doesn't have a trial timeout, newer versions do).

Also sometimes I use an old version of PaintShop Pro to apply transparancy to the image if it didn't exist already.

After that I just use the build in LabVIEW primitive "Read From Binary File" to read the file - that is, I create a new Untitled VI, insert the "Read From Binary File" function, wire the path input to a control, point it to the image file of your choice, wire a constant of -1 to the Count input (to have it read the whole file), and finally I create an indicator on the Data output terminal. Then I run the VI ;)

Once the file is read and the content is displayed in the front panel indicator I go to the block diagram and right click on the indicator terminal and do a 'Convert to Constant' on it. Be aware though, some resizing is probably required..

There you go..

Happy coding

Share this post


Link to post
Share on other sites

Whenever I find myself in need of a new tray icon, I usually do a search on Iconarchive or Google using descriptive terms for the pictures I have in mind.

I then download the images or icon files I find interresting, or just the ones I think looks cool :D

If the file is an icon file I use an icon editor to remove icons bigger then 32x32px in the file (I stick with IcoFX v1.6.4 - mainly because its simple and doesn't have a trial timeout, newer versions do).

Couple things. I have used Gimp in the past for icon file editing which supports transparencies and multiple icons (as layers) but does have limitations as far as usability to I may try IcoFX.

Another thing, which may be better in a new post, is what is the restrictions on using icons from sites like the one you posted? It has a "Commercial Icons" section which is where you need to pay to use the icons in a commercial application or website. I don't intend on using it for a commercial application, but a work related one. Does that mean I don't need to pay to legally use these icons? I'm sure most people would just grab images from a Google search and use them without thinking about it, and maybe I should too, but I am just curious about what is legal.

Share this post


Link to post
Share on other sites

Another thing, which may be better in a new post, is what is the restrictions on using icons from sites like the one you posted? It has a "Commercial Icons" section which is where you need to pay to use the icons in a commercial application or website. I don't intend on using it for a commercial application, but a work related one. Does that mean I don't need to pay to legally use these icons? I'm sure most people would just grab images from a Google search and use them without thinking about it, and maybe I should too, but I am just curious about what is legal.

Of course you're right,..whenever you are using material that are widely available or easily downloadable, there's a potential risk that you're actually crossing the legal boundary, and

maybe without even knowing it. I for one don't really check if every little icon picture I download and use in my own programs at home, are protected or covered by some legal rights.

However, that doesn't mean that I totally disregard the fact that some rules do apply!

For instance, I always stick to the Icon packages that we have bought and payed for in the company, when I do software that will end up at a customers site somewhere!

Share this post


Link to post
Share on other sites

Hi

I got a new challenge :-)

I would like to password protect the possibility to open the program after it has been sent to tray.

I made a small password VI to popup when the user dobble click the tray icon, but I can't make the password VI to focus in the input control.

I have placed the VI before the functions that make the example visible and made at case around it to respond on correct password.

If i place the PW VI in the event case for ballon tip and press the show tip, the PW popup and focus in the input field.

I would appreciate i any one got clue what to do.

Thanks in advance.

Bjarne

Share this post


Link to post
Share on other sites

You can set the focues of a VI with the control property 'Has Focus'.

The following snippets, loads a string, sets focus and selects the whole string:

post-2399-0-46373900-1352148366.png

Ton

Share this post


Link to post
Share on other sites

Hi Ton

Thank you, but it's not my problem to set a control in focus.

The problem is that the frontpanel of my application is hidden and when I dobble click the Icon in the tray, the Password VI popup but it is not the active window!

Se the snippets:

This is my password VI

post-7489-0-64221300-1352725257_thumb.pn

I call it from here in the example for the "Icon in tray"

post-7489-0-80610400-1352725212_thumb.pn

regards Bjarne

Edited by Bjarne Joergensen

Share this post


Link to post
Share on other sites

The problem is that the frontpanel of my application is hidden and when I dobble click the Icon in the tray, the Password VI popup but it is not the active window!

You will need to make some calls to reorder the windows. User32.dll has "SetFocus", "ShowWindowAsync" and "SetWindowPos" functions in it. I've not found a foolproof way to get a window on top and with focus, but those are what I'm using.

Share this post


Link to post
Share on other sites

You will need to make some calls to reorder the windows. User32.dll has "SetFocus", "ShowWindowAsync" and "SetWindowPos" functions in it. I've not found a foolproof way to get a window on top and with focus, but those are what I'm using.

Hi Tim_S

Thank you :yes:

I found this thread: http://lavag.org/topic/12751-how-do-you-make-your-application-window-frontmost/page__p__76280__fromsearch__1

That was what i needed :thumbup1:

Thank you all for helping :beer_mug:

Cheers Bjarne

Share this post


Link to post
Share on other sites

Stinus,

 

great code, thanks for posting :worshippy:

 

I've put together an application and it works beautifully... untill I call the VIs from TestStand. The icon refuses to show up in the tray. :(

Any idea, what could cause this? I don't have much experience with the underlying .net

 

Cheers

Oli

 

Share this post


Link to post
Share on other sites

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.