Shoutbox

Check if window is already open? - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: Check if window is already open? (/showthread.php?tid=77241)

Check if window is already open? by Jimbo on 09-04-2007 at 05:16 PM

Ive been told to ask this by Spunky because his internet is fuxxored.

Is there any other way of ensuring that only one instance of a window is open other than using:

code:
try{
wnd.close(1);
}catch(E){}


RE: Check if window is already open? by Matti on 09-04-2007 at 06:52 PM

Well, the way I do it is by creating a global array where I store all my opened PlusWnd objects in. Then, in my general window creator function, I say that if typeof Wnd[WndId] == "object", it should focus the existing window instead of opening a new one. But you must remember that in all OnWndIdEvent_Destroyed events, you should set the value of the window's member in the array to false, or remove it from the array.

You can see a working example of this in all of my scripts, the most recent is Log Manager, but Countdown Live and Calculator also have such (older) functions. Feel free to copy/modify/mess with the code you need to do this, but please ask for permission if you want to copy some other sh*t. :P