-
Try out the new Jake: AI Coding Assistant for LabVIEW (beta)!
Get answers to questions about LabVIEW and discuss your code.
Windows System Tray Notification Icon by Brinoceros - Toolkit for LabVIEW Download
Version | 0.0.0.0 |
Released | Jan 27, 2017 |
Publisher | Brinoceros |
License | MIT |
LabVIEW Version | LabVIEW>=9.0 |
Operating System | Windows |
Project links | Homepage |
Description
This is a LabVIEW API for creating an icon in the Windows system tray (AKA notification area), complete with nested menus and events. It uses the .NET framework NotifyIcon class. While developing this, I found this similar implementation, but continued with my own to implement a few more features I required.
f you are looking around for a way to have a system tray icon for your LabVIEW application, as I was, you'll find that .NET is the way to go. You can try calling the Win32 API via Shell32.dll function Shell_NotifyIcon, as suggested here, but that is often difficult to do from LabVIEW directly. You will also have a very hard time getting events, such as mouse clicks on the icon or menus, back to LabVIEW. Another option is existing ActiveX wrappers people have made. NI has one that comes with CVI (posted here), and there are others around the web that are sometimes free but sometimes not (random example, random example, VI wrapped example). ActiveX gives a nice API and solves the event issue, but you are limited to the features that have been exposed to you through that particular ActiveX wrapper, which is up to the wrapper developer. However, .NET acting as the new Windows API gives a nice, featured interface that is easy to use from LabVIEW.
NotifyIcon Palette.png
Features:
Basic stuff:
Dynamically change icon.
Show Balloon Tips.
Create context menus (right-click menu)
Examples!
More interesting stuff:
Events captured by LabVIEW event structure. Rather than have each event (menu click, balloon tip click, icon double-click, etc.) fire their own callback VI, I let the developer decide which events to capture, then those events are all sent to the LabVIEW Event structure as a NotifyIcon User event. Check out the included examples to see how this works. The idea is that all events are piped to 1 location and handled by the structure, instead of having VIs fire at will.
NotifyIcon Event Example.png
Create nested context menus. I actually decided this would be a fun case for trying out the new native recursion in LabVIEW, so you can nest menus to your heart's content Overkill? yes, but it's fun, and better than not being able to nest menus at all like in most of the ActiveX implementations I tried.
NotifyIcon menus.png
Return a reference to any MenuItem. To go with the nested menus, you can call this recursive code to return a reference to any MenuItem. You can then make any direct .NET calls to change useful properties like Visible, or Checked. Again, see the examples.
NotifyIcon misc examples.png
VIs are saved in LabVIEW 2009, and this was developed with .NET 3.5. I you have a different .NET version/requirement just give it a try. I would be surprised if this wasn't pretty backward/forward compatible.
Installation instructions: Download NotifyIcon.zip, then unzip to your user.lib folder and restart LabVIEW.
BUG FIX 4/5/2011 - Some LabVIEW references to objects were not being properly closed, though the objects themselves were being destroyed. This could cause a memory leak which would be noticable if you do a lot of icon or menu changing. NotifyIcon.zip has been updated to fix this. Thanks to DSmith for finding the issue. See the comment from DSmith below for more information.
Steps to Implement or Execute Code
Run either of the two examples included in the attachment for guidance on using this API.