PDA

View Full Version : Cant restore/show system tray window?


SonG0han
11-06-2005, 08:16 AM
Hi! I have my app set to "system tray" mode but it seems you cant minimize and restore it via the built in window actions. even if I get the winhandle again (there is non in system tray?) after minimizing it it does not get restored.

I tried window.hide and window.show but I get this error in debug mode:
TRACE: LastError = 2005 ("Error, could not show window.")

its the same issue, right? It has no winhandle as system tray icon?
but its still shown so I dont know why it says "could not show". Restoring does not work at all.

rhosk
11-06-2005, 08:32 AM
Try Window.Hide / Show (instead of Window.Minimize when running via sys tray). You get the same results.

Whoops, read yer post again. I just tried the Window.Hide method (as I posted avove) using just system tray, and it worked here. You may have something else going on?

Granted the minimize method doesn't work I believe because the window must be active and it's kinda hidden in the sys tray as you summized.

SonG0han
12-31-2005, 02:10 PM
I added a traymenu but cant restore the window. I tried window.show and window.restore and even if I save the winID in a variable when I minimize it it can't be opened with this windowid (getwinhandle function). :(

is there no way to make my "open" button in traymenu work?

Intrigued
12-31-2005, 08:07 PM
I modified the code in the AMS 6 Help file to the following (note: what's in bold):

function g_OnSystemTrayMenu(X, Y)
tblMenu = {};
tblMenu[1] ={};
tblMenu[1].Text = "&New Menu";
tblMenu[1].ID = 100;
tblMenu[1].Checked = false;
tblMenu[1].Enabled = true;
tblMenu[1].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;
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;

result = Application.ShowPopupMenu(X, Y, tblMenu, TPM_RIGHTALIGN, TPM_BOTTOMALIGN, true, false);

if result == 101 then
Application.Restore()
end

end