关闭

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

311人阅读 评论(0) 收藏 举报
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();//将程序放入托盘 
               } 
        }  
       
0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:360186次
    • 积分:4659
    • 等级:
    • 排名:第6273名
    • 原创:152篇
    • 转载:28篇
    • 译文:1篇
    • 评论:25条
    文章分类
    最新评论