Labview 实现系统托盘效果

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/ferrycooper/article/details/83245605

      系统托盘即类似QQ最小化后显示在电脑右下角通知栏里的小图标一样的东西,双击或其它动作主界面又显示出来。.Net 上实现这种效果的是NotifyIcon类具体实现方法自行百度,但labview 上又该怎么实现好像没有什么好的方法,还得借助.Net技术来实现。

       写一个简单的vi,界面上只有三个控件两个按钮一个指示灯,功能很简单当点击开始运行按钮指示灯开始闪烁,点击停止指示灯停止闪烁程序也随之停止。前面板和程序框图分别如下:

      

      

   

       下面实现最小化和关闭窗体时软件运行于系统托盘,借助于.NET 平台的NotifyIcon类,在labview中需要通过构造器节点创建NotifyIconIcon等。

       系统托盘图标放在主vi目录下

      

     

        根据微软官方的解释:通知区域中的图标是计算机的快捷方式,如病毒防护程序或音量控制后台运行的进程。Icons in the notification area are shortcuts to processes that are running in the background of a computer, such as a virus protection program or a volume control. 这些进程不会使用其自己的用户界面。These processes do not come with their own user interfaces. NotifyIcon类的此功能提供程序的方法。The NotifyIcon class provides a way to program in this functionality. Icon属性定义在通知区域中显示的图标。The Icon property defines the icon that appears in the notification area. 图标的弹出菜单都与ContextMenu属性。Pop-up menus for an icon are addressed with the ContextMenu property. Text属性指定工具提示文本。The Text property assigns ToolTip text. 为了使图标以显示在通知区域中,Visible属性必须设置为true。

      NotifyIcon类构造如下: 

    

       前面板关闭事件处理,当前vi隐藏并根据获取到的NotifyIcon class provides a way to program in this functionality.引用调用相关的提示方法:

      

      NotifyIcon双击事件通过事件注册节点调用回调函数把当前vi引用当参数传入回调vi

     

     回调vi 程序框图如下:

    

    整体程序框图如下:

运行效果:

 

这里不知怎么加附件源文件只有上传到资源栏目了:https://download.csdn.net/download/ferrycooper/10735573

猜你喜欢

转载自blog.csdn.net/ferrycooper/article/details/83245605