AIR程序如何最小化到系统托盘(2)

public function createSystrayRootMenu():NativeMenu{ 
                var menu:NativeMenu = new NativeMenu(); 
                var openNativeMenuItem:NativeMenuItem = new NativeMenuItem("打开程序");//生成OPEN菜单项 
                var exitNativeMenuItem:NativeMenuItem = new NativeMenuItem("退出程序");//同理 
                openNativeMenuItem.addEventListener(Event.SELECT, undock); 
                exitNativeMenuItem.addEventListener(Event.SELECT, function(event):void{stage.nativeWindow.close();});//添加EXIT菜单项事件 
                menu.addItem(openNativeMenuItem); 
                menu.addItem(new NativeMenuItem("",true));//separator   
                menu.addItem(exitNativeMenuItem);//将菜单项加入菜单  
                return menu; 
          } 
      private function setSystemTrayProperties():void{ 
              SystemTrayIcon(NativeApplication.nativeApplication .icon).tooltip = "我的常用软件";
              SystemTrayIcon(NativeApplication.nativeApplication .icon).addEventListener(MouseEvent.CLICK, undock); 
              stage.nativeWindow.addEventListener(NativeWindowDisplayStateEvent.DISPLAY_STATE_CHANGING, nwMinimized);   
         }
         private function nwMinimized(displayStateEvent:NativeWindowDisplayStateEvent):void { 
               if(displayStateEvent.afterDisplayState == NativeWindowDisplayState.MINIMIZED) { 
                  displayStateEvent.preventDefault();//阻止系统默认的关闭窗体事件 
                  dock();//将程序放入托盘 
               } 
        }  
       
阅读更多
文章标签: air function menu
个人分类: flex
上一篇AIR程序如何最小化到托盘(1)
下一篇AIR程序如何最小化到系统托盘(3)
想对作者说点什么? 我来说一句

教你怎么样把程序最小化到托盘

2012年11月13日 2.2MB 下载

没有更多推荐了,返回首页

关闭
关闭