View Full Version : is there any way to create a menu but i open it from tray
melissa
06-08-2007, 09:41 AM
hi everyone
is there any way to create a menu but i open it from tray
for example like this
http://img443.imageshack.us/img443/6196/untitleddz9.png
many thanks
RizlaUK
06-08-2007, 10:20 AM
yes, you can change the system tray menu to anything you want (but without icons unfortunately)
look here
http://www.indigorose.com/forums/showpost.php?p=66333&postcount=2
wasim21k
06-08-2007, 10:30 AM
first RizlaUK welcome back. and thanks for pointing in right direction. (it helped me as well)
melissa
06-08-2007, 10:45 AM
thank you RizlaUK answering me..... but you know what that`s really hard
for me to inderstand the code you gave me ....if you can make an example
for that plz...and sorry to take from your time
manny thanks
wassim21k if you undestood that can you make for me an example
RizlaUK
06-08-2007, 11:32 AM
ok, there is realy not much point of a example as the code simply goes in global functions and thats it,
i have commented the code a bit for you so you can understand how it works and how to customize it
place this code in globals and then preview your project, look at the menu and you see how it is laid out, then go back in to globals and edit the menu to suit your needs
function g_OnSystemTrayMenu(X, Y)
tblMenu = {};
-- this is menu item 1
tblMenu[1] ={}; -- this line defines the menu item number
tblMenu[1].Text = "&New Menu 1"; -- this line defines the menu item text
tblMenu[1].ID = 100; -- this line defines the menu item ID (must increment as your menu grows)
tblMenu[1].Checked = false; -- set if the menu item is checked
tblMenu[1].Enabled = true; -- set if the menu item is enabled
-- this is submenu item 1 for menu item 1 (delete if submenu is not needed)
tblMenu[1].SubMenu = {}; -- this line defines the submenu
tblMenu[1].SubMenu[1] = {};
tblMenu[1].SubMenu[1].Text = "&SubItem 1";
tblMenu[1].SubMenu[1].ID = 101;
tblMenu[1].SubMenu[1].Checked = false;
tblMenu[1].SubMenu[1].Enabled = true;
-- this is submenu item 2 for menu item 1 (delete if submenu is not needed)
tblMenu[1].SubMenu[2] = {};
tblMenu[1].SubMenu[2].Text = "S&ubItem 2";
tblMenu[1].SubMenu[2].ID = 102;
tblMenu[1].SubMenu[2].Checked = false;
tblMenu[1].SubMenu[2].Enabled = true;
-- this is menu item 2
tblMenu[2] ={};
tblMenu[2].Text = "&New Menu 2";
tblMenu[2].ID = 200;
tblMenu[2].Checked = false;
tblMenu[2].Enabled = true;
tblMenu[2].SubMenu = {};
-- this is submenu item 1 for menu item 2 (delete if submenu is not needed)
tblMenu[2].SubMenu[1] = {};
tblMenu[2].SubMenu[1].Text = "&SubItem 1";
tblMenu[2].SubMenu[1].ID = 201;
tblMenu[2].SubMenu[1].Checked = false;
tblMenu[2].SubMenu[1].Enabled = true;
-- this is submenu item 2 for menu item 2 (delete if submenu is not needed)
tblMenu[2].SubMenu[2] = {};
tblMenu[2].SubMenu[2].Text = "S&ubItem 2";
tblMenu[2].SubMenu[2].ID = 202;
tblMenu[2].SubMenu[2].Checked = false;
tblMenu[2].SubMenu[2].Enabled = true;
-- this is menu item 3
tblMenu[3] ={};
tblMenu[3].Text = "&New Menu 3";
tblMenu[3].ID = 300;
tblMenu[3].Checked = false;
tblMenu[3].Enabled = true;
result = Application.ShowPopupMenu(X, Y, tblMenu, TPM_RIGHTALIGN, TPM_BOTTOMALIGN, true, false);
-- this code checks for which menu item was clicked
if(result ~= -1)then
if result == 101 then
result = Dialog.Message("Notice", "You clicked \"Menu 1 SubItem 1\"");
elseif result == 102 then
result = Dialog.Message("Notice", "You clicked \"Menu 1 SubItem 2\"");
elseif result == 201 then
result = Dialog.Message("Notice", "You clicked \"Menu 2 SubItem 1\"");
elseif result == 202 then
result = Dialog.Message("Notice", "You clicked \"Menu 2 SubItem 2\"");
elseif result == 300 then
result = Dialog.Message("Notice", "You clicked \"Menu 3\"");
end
end
end
Hope that helps
melissa
06-11-2007, 07:25 AM
i`m really sorry RizlaUK to take from your time and you are really helpfull i will
try and i tell you later :yes
melissa
06-11-2007, 07:58 AM
anyway this is my little project ..
melissa
06-12-2007, 09:16 AM
the code is working thank you RizlaUK but i have to write a lot if i want add
something and i focus ...thank you
RizlaUK
06-12-2007, 09:33 AM
thats the thing, custom menus do take a lot of code but i think its worth it for the *pro* look
qwerty
06-12-2007, 12:49 PM
Thanks RizlaUK,
working good for me too, just need to work out now how to make those menu selections = the actions form when i click a button in my project, and how to work the restore minimise thing so it operates the same as standard one, and then the Always on Top tick box thing ... i'll get there.... eventually !!
TJ_Tigger
06-13-2007, 06:09 AM
Thanks RizlaUK,
working good for me too, just need to work out now how to make those menu selections = the actions form when i click a button in my project, and how to work the restore minimise thing so it operates the same as standard one, and then the Always on Top tick box thing ... i'll get there.... eventually !!
The IR Project Code Viewer in the example forum has a tray menu built within it. There is a restore and minimize option as well. Maybe that will help with some of the coding. There is a link in my sig.
Tigg
qwerty
06-13-2007, 06:19 AM
thanks tigg ... i actually managed to get it all sorted last night .... i will still look at that example as it will probably show me a better way to go about it all, my menu having 17 entries in total (inculding spaces) resulted in a stupidly large amount of code in the Global Functions section, but it works.
Only thing i didnt do was to make the minimise and restore options disabled dependant on the current state, as i found using the restore option to simply bring the project to the top was quite handy as i have only the tasktray icon when the project is running, and if you try and minimise something that is already minimised then it has no affect !!
I posted my solution in a seperate thread so if anyone was searching purely for menu tips on task tray menu's it would return in their search
qwerty
06-13-2007, 06:50 AM
EDIT: ... grabed it and it helped me real fast to do the divders/spacers properly in the menu and i also managed to grab the section to enable/disable the restore/minimise options which looks a lot better :) ... cheers
Intrigued
06-13-2007, 05:10 PM
'Tiggs a good guy and still my "go to" guy for advanced Table (Array) questions. I'm thinking of putting a tagline on my products as such, "Tigg inside!", with a catchy mouse short.
@ 'Tigg --- > :D
Imagine Programming
01-30-2008, 05:09 PM
this has been a great helping hand to me aswell, thanks:)
Imagine Programming
01-31-2008, 12:51 PM
okay i got the menu working, but uhhh how can i get one of the menu items the default item (for double click) and also get that item in bold?
Imagine Programming
01-31-2008, 02:43 PM
something else, how can i get the item *Hide (minimize tot systray) disabled when i minimize, and how can i get show(restore) disabled when its restored?
RizlaUK
01-31-2008, 02:48 PM
where you have "Restore" in your menu block of code, replace it with this:
you will need to edit the menu table item number and item ID number to suit your menu
local WindowState = DLL.CallFunction(_SystemFolder.."\\user32.dll", "IsWindowVisible", Application.GetWndHandle(), DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL)
WindowState = String.ToNumber(WindowState);
if WindowState == 0 then
tblMenu[2] ={};
tblMenu[2].Text = "&Maximize";
tblMenu[2].ID = 300;
tblMenu[2].Checked = false;
tblMenu[2].Enabled = true;
else
tblMenu[2] ={};
tblMenu[2].Text = "&Minimize";
tblMenu[2].ID = 300;
tblMenu[2].Checked = false;
tblMenu[2].Enabled = true;
end
EDIT: i dont think you can set the font on menu items in AMS, when you say default do you mean checked, if so then check the below post for some handy menu helper functions
http://www.indigorose.com/forums/showthread.php?t=13244&highlight=adjust+menu
Imagine Programming
02-02-2008, 05:21 AM
Thanks rizla, but it doesnt work on minimize... restore will stay in the menu when i restore... i think its because when you minimize ams is not able to edit something in global functions...
RizlaUK
02-02-2008, 02:35 PM
strange, it works for me, i'll dig out the apz in a bit and post it for you
Imagine Programming
02-03-2008, 10:50 AM
thanks, you maybe have already noticed that i am into systray atm hehe, popup and contexmenu ^^
RizlaUK
02-03-2008, 02:54 PM
ok, heres the original post that the above bit of code come from, there is a example apz there, it all relates to the tray menu, theres some handy tricks in there,
http://www.indigorose.com/forums/showpost.php?p=94468&postcount=8
Imagine Programming
02-10-2008, 05:27 AM
Thanks again rizla:)
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.