PDA

View Full Version : "Always on Top" tray menu option


qwerty
06-12-2007, 02:05 PM
hiya guys,

been playing with a custom menu from the tray icon, got 99% of it all sorted from looking through old posts, just stuck on one feature i'd like :P

i would like an "Always on Top" option that is "unchecked" on first running the project (as it is set to normal and NOT always on top in the settings) but will change to "checked" when that menu option is selected, i know how to change the window state setting, i just dont know how do get that value, or how to change the checked/unchecked state of the menu command.

As i can't see any option for getting the window state (Zorder) to compare it to another state, i was thinking that the way to go would be to switch the menu id state between checked and unchecked, and then setting the window Zorder relative to that result.

or is there a way to manipulate the projects settings once it has been compiled ...... or am i making no sense what so ever to you guys !!!!

qwerty
06-12-2007, 04:04 PM
i finally figured it out :D :D

the problem i had was that all the examples were based on doing this from a menu bar and not a menu in the task tray, using the On_Menu scripting section, whereas from the tasktray icon this wont work.
Here's what i did, hopefully it will be of some help to others if they are searching this.

All the code went in the Global section,

to control the check mark in the menu i added this just after the "function g_OnSystemTrayMenu(X, Y)" Line

state = Registry.GetValue(2, "Software\\Auto Desc", "OnTop", false);
if (state ~= "Yes") then
On_Top = false
else
On_Top = true
end


Then for the "tblMenu[2].Checked" property i put "On_Top" in the place of true/false ... [2] being my menu id

then in the action to perform in the event of that menu option being selected, i put this..

current_state = Registry.GetValue(2, "Software\\Auto Desc", "OnTop", false);
if (current_state == "Yes") then
Registry.SetValue(2, "Software\\Auto Desc", "OnTop", "No", REG_SZ);
Window.SetOrder(Application.GetWndHandle(), HWND_NOTOPMOST);
else
Registry.SetValue(2, "Software\\Auto Desc", "OnTop", "Yes", REG_SZ);
Window.SetOrder(Application.GetWndHandle(), HWND_TOPMOST);
end



works like a charm :)

thetford
06-12-2007, 04:08 PM
I have considered doing something like that, thanks for sharing! :yes

qwerty
06-12-2007, 04:16 PM
your welcome, glad it's of some help :)

qwerty
06-13-2007, 04:33 AM
:( i found a bug....

the menu checked condition is remembered if you close your project while it is set to "always on top" however, the actual on top command isnt, so to ensure the menu is cleared on each run of your project, place this in the "On Preload" section of your project properties.


-- Reset on top marker --
Registry.SetValue(2, "Software\\Auto Desc", "OnTop", "No", REG_SZ);


it would be nice if it could remember the setting completely, but for my purpose it's not important