Language: ChineseGermanSpanishFrenchDutchItalianRussian
123 Flash Chat Forums

Go Back   TOPCMM Community > SWFKit > SWFKit Support

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-09-2005, 07:06 PM
Junior Member
 
Join Date: Dec 2005
Posts: 14
Default change system tray menu according to main window status

hi,
I'm just having a problum , how change system tray menu according to window staus .

if windowState = minimized , just want have tray menu "maximized", else
menu should only "close"
Reply With Quote
  #2 (permalink)  
Old 12-10-2005, 10:23 AM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re:change system tray menu according to main window status

1. create your own menu
2. handle the onUpdateItem event of the menu


Code:
Application.Behaviour.bShowInSystemTray = true;
Application.SysTray.useDefaultHandler = false;

Application.SysTray.add();

Application.SysTray.onRClicked = function ()
{
    var menu = new Menu;
    menu.createPopupMenu();
    menu.appendItem("minimize", "minimize");

    getMainWnd().bringToTop();
    if (menu.show() == "minimize") getMainWnd().windowState = "minimized";
}

Menu.onUpdateItem = function (id, state)
{
if (id == "minimize") 
state.enable = getMainWnd().windowState != "minimized";
}
Reply With Quote
  #3 (permalink)  
Old 12-11-2005, 06:11 AM
Junior Member
 
Join Date: Dec 2005
Posts: 14
Default Re:change system tray menu according to main window status

Thanks for the prompt help.
This code is working fine as it is and I tried same coding approach to have 3 menu Items
(Minimize, Maximize, Close) and I'm getting 2 problems.

1. Menu Item activation and deactivation is fine, but when I click on any active menu Item, menu pops twice.
E.g. If I click on minimize, it won’t minimize the window but menu pops again beside, if I click again it executes the minimizing action.

2. How do I incorporate same set of coding to "FlashPlayer.onContextMenu" function?


Code:
Application.Behaviour.bShowInSystemTray = true;
Application.SysTray.useDefaultHandler = false;
//Application.setDragRegion(left, top, width, height); 
Application.setDragRegion(0,0, 600, 30); 
Application.SysTray.tip = "test 1"
Application.SysTray.add();
Application.SysTray.onRClicked = function ()
{
    var menu = new Menu;
    menu.createPopupMenu();
    menu.appendItem("01", "Minimize");
    menu.appendItem("02", "Maximize");
   // menu.appendItem("03", "Close");
    
    getMainWnd().bringToTop();
    if (menu.show() == "01") getMainWnd().windowState = "Minimized";
if (menu.show() == "02") getMainWnd().windowState = "normal";    
    }
Menu.onUpdateItem = function (id, state)
{
   if (id == "01")
      state.enable = getMainWnd().windowState != "minimized";
  else if (id == "02")
   state.enable = getMainWnd().windowState != "maximized";
    }

Application.SysTray.onLClicked = function ()
{
getMainWnd().windowState = 'normal';
getMainWnd().bringToTop();
}
return true;
Reply With Quote
  #4 (permalink)  
Old 12-11-2005, 06:19 AM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re:change system tray menu according to main window status

Because you display the menu twice in the code

Code:
 if (menu.show() == "01") getMainWnd().windowState = "Minimized";
   if (menu.show() == "02") getMainWnd().windowState = "normal";

it should be
Code:
var id = menu.show();
if (id == "01") getMainWnd().windowState = "Minimized";
else if (id == "02") getMainWnd().windowState = "normal";
Reply With Quote
  #5 (permalink)  
Old 12-11-2005, 07:44 AM
Junior Member
 
Join Date: Dec 2005
Posts: 14
Default Re:change system tray menu according to main window status

Thanks a lot. Error noted.
Hope this post will help others as well so I decided to place my corrected code here for all kit lovers. Thanks again admin.


Code:
//Initialize

Application.Behaviour.bShowInSystemTray = true;
Application.SysTray.useDefaultHandler = false;
//Application.setDragRegion(left, top, width, height); 
Application.setDragRegion(0,0, 600, 30); 
Application.SysTray.tip = "test1"
Application.SysTray.add();

Application.SysTray.onRClicked =
FlashPlayer.onContextMenu = function ()
{
var menu = new Menu;
menu.createPopupMenu();
menu.appendItem("min", "Minimize");
menu.appendItem("max", "Maximize");
menu.appendItem("cl", "Close");
getMainWnd().bringToTop();
var id = menu.show();
if (id == "min") getMainWnd().windowState = "minimized";
else if (id == "cl") getMainWnd().close();
else if (id == "max") getMainWnd().windowState = "normal";
}
Menu.onUpdateItem = function (id, state)
{
if (id == "min")
state.enable = getMainWnd().windowState != "minimized";
else if (id == "max")
state.enable = getMainWnd().windowState != "normal";
}
Reply With Quote
  #6 (permalink)  
Old 12-11-2005, 08:44 AM
Junior Member
 
Join Date: Dec 2005
Posts: 14
Default Re:change system tray menu according to main window status

Hi All,

Finally I got an idea to redesign a more flexible coding and it is very easy to customize. I’m sure all of you will like it. Here is my final final coding.

Code:
//Initialize

Application.Behaviour.bShowInSystemTray = true;
Application.SysTray.useDefaultHandler = false;
//Application.setDragRegion(left, top, width, height); 
//Application.setDragRegion(0,0, 600, 30); 
Application.SysTray.tip = "test1"
Application.SysTray.add();

Application.SysTray.onRClicked =
FlashPlayer.onContextMenu = function ()
{
var menu = new Menu;
menu.createPopupMenu();
menu.appendItem("min", "Minimize");
menu.appendItem("max", "Maximize");
menu.appendItem("cl", "Close");
getMainWnd().bringToTop();
var id = menu.show();
if (id == null) return;
switch (id)
{
case "cl": /*exit*/
getMainWnd().close();
break;

case "min": /*minimize*/
getMainWnd().windowState = "minimized";
getMainWnd().hide();
Application.SysTray.balloonTip = "Click on the system tray icon to restore your Movie back.";
Application.SysTray.balloonTitle = "test1";
Application.SysTray.showBalloonTip();
break;

case "max": /*restore*/
getMainWnd().windowState = "normal";
break;
}
}
Menu.onUpdateItem = function (id, state)
{
if (id == "min")
state.enable = getMainWnd().windowState != "minimized";
else if (id == "max")
state.enable = getMainWnd().windowState != "normal";
}
Application.SysTray.onLClicked = function ()
{
getMainWnd().windowState = 'normal';
getMainWnd().bringToTop();
}
return true;
Reply With Quote
Reply

Was this information helpful?    Yes No



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 02:05 AM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.