Popular Post Stinus Olsen Posted March 30, 2011 Popular Post Report Share Posted March 30, 2011 Hi everyone A couple of weeks ago i had the need to put a small suite of applications i made in the tray area, but the VIs i could find to do this wasn't really very intuitive or was lacking the functions i needed. The solution? Another one of these put-your-LabVIEW-app-in-the-tray toolsets .. but this time, a little better wrapped than the example code you can find on NI's site.. ;-) (no offense) So here it is for you to evaluate .. it's not anything near final, and one can always find a number of small features lacking, but hey..it's event based, and its pretty easy to add more events if ever needed :-) Notes: Code is currently for LV8.6 and requires at least .NET Runtime 2.0, but i know for a fact that it runs on Win7 and LV2010.. Installation: Unpack / Extract contained "Notify Icon" folder into your user.lib and refresh palettes or restart LabVIEW.. Examples: Browse into your user.lib -> Notify Icon palette and drag the "NotifyIcon Class Example" VI to your block diagram (or open it by browsing into the "user.lib\Notify Icon\Example" folder) 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.. Feel free to send me any comments / questions AND bugfixes / error-reports Thanks Stinus Well..since FF4 doesn't want to play nice.. here is the code uploaded using good old IE :-/ Notify Icon.zip 9 Quote Link to comment
hooovahh Posted March 30, 2011 Report Share Posted March 30, 2011 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. Quote Link to comment
hugo_fr Posted March 30, 2011 Report Share Posted March 30, 2011 Nice work Hugo Quote Link to comment
S59X Posted March 30, 2011 Report Share Posted March 30, 2011 Very nice. I've been looking for this functionality also. Thank you for sharing this. Great! Mirko Quote Link to comment
viSci Posted March 30, 2011 Report Share Posted March 30, 2011 Beautiful clean code, thanks for sharing! Quote Link to comment
Stinus Olsen Posted March 30, 2011 Author Report Share Posted March 30, 2011 Thanks for the feedback and positive comments.. Hope you put it to some good use in those GUI's out there... / Zero Quote Link to comment
crelf Posted May 2, 2011 Report Share Posted May 2, 2011 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! Quote Link to comment
Omar Mussa Posted May 12, 2011 Report Share Posted May 12, 2011 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)" If the clicked events could specify whether there was a right-mouse vs left-mouse click on a given menu/tray/balloon tip If the balloon tip clicked event returned the balloon tip text Thanks for your contribution to the community! Quote Link to comment
Brinoceros Posted May 16, 2011 Report Share Posted May 16, 2011 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 ) 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. Quote Link to comment
Stobber Posted May 16, 2011 Report Share Posted May 16, 2011 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!) 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. 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. 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. Using the name of the library to namespace the VIs is ghetto. Why not add them to an lvlib? There are few enough that load times and memory bloat won't be an issue. 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. 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 2 Quote Link to comment
dannyt Posted May 17, 2011 Report Share Posted May 17, 2011 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 Quote Link to comment
Stinus Olsen Posted May 17, 2011 Author Report Share Posted May 17, 2011 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)" If the clicked events could specify whether there was a right-mouse vs left-mouse click on a given menu/tray/balloon tip 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! 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 ) 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 Quote Link to comment
BrentonLang Posted July 25, 2012 Report Share Posted July 25, 2012 This is great! I'll be adding this functionality in my current project. Thanks again. Quote Link to comment
Bjarne Joergensen Posted October 2, 2012 Report Share Posted October 2, 2012 Hi Use this in my new project now. So happy 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 Quote Link to comment
Stinus Olsen Posted October 17, 2012 Author Report Share Posted October 17, 2012 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 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 Quote Link to comment
hooovahh Posted October 17, 2012 Report Share Posted October 17, 2012 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 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. Quote Link to comment
Stinus Olsen Posted October 17, 2012 Author Report Share Posted October 17, 2012 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! Quote Link to comment
Bjarne Joergensen Posted October 21, 2012 Report Share Posted October 21, 2012 Thank you. It's working now I did try "Read from binary file" without success, but the pass through a icon editor did the job. Regards Bjarne Quote Link to comment
Bjarne Joergensen Posted November 5, 2012 Report Share Posted November 5, 2012 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 Quote Link to comment
Ton Plomp Posted November 5, 2012 Report Share Posted November 5, 2012 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: Ton Quote Link to comment
Bjarne Joergensen Posted November 12, 2012 Report Share Posted November 12, 2012 (edited) 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 I call it from here in the example for the "Icon in tray" regards Bjarne Edited November 12, 2012 by Bjarne Joergensen Quote Link to comment
Tim_S Posted November 12, 2012 Report Share Posted November 12, 2012 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. Quote Link to comment
Bjarne Joergensen Posted November 13, 2012 Report Share Posted November 13, 2012 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 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 Thank you all for helping Cheers Bjarne Quote Link to comment
oli_wachno Posted May 9, 2014 Report Share Posted May 9, 2014 Stinus, great code, thanks for posting 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 Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.