What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Focusing a window

Focusing a window
Author: Message:
MeEtc
Patchou's look-alike
*****

Avatar
In the Shadow Gallery once again

Posts: 2200
Reputation: 60
38 / Male / Flag
Joined: Nov 2004
Status: Away
O.P. Focusing a window
I'm trying to set a opened window to be focused if the user tries to open a second window instead, so that only one window can be open at the same time. The problem I'm having, is that the variable I'm trying to work with doesn't appear to be a PlusWnd object, but I'm sure it is.

In one block of code, a window is created:
code:
openwnd = MsgPlus.CreateWnd("yass_gui.xml","WndConfig");
openwnd is a global variable.

Now, when this window is open and another is attempted to be opened...
code:
function OnEvent_MenuClicked(ControlId, Location, OriginWnd){
   switch(ControlId){
      case "settings":
         if(openwnd != undefined){
            Debug.Trace(typeof(openwnd));
            Debug.Trace(openwnd.Handle);
            Interop.Call('User32', 'SetForegroundWindow', openwnd.Handle);
            return;
         }
// more code ...
When this runs, I get:
code:
object
Error: unknown (code: -2147418113)
       File: yass_menu.js. Line: 24.
Function OnEvent_MenuClicked returned an error. Code: -2147352567
Line 24 is the second Debug statement.

So, whats going on with the openwnd variable? And how to I set focus to it?
[Image: signature/]     [Image: sharing.png]
I cannot hear you. There is a banana in my ear.
03-14-2008 10:09 PM
Profile PM Web Find Quote Report
vikke
Senior Member
****

Avatar

Posts: 900
Reputation: 28
31 / Male / Flag
Joined: May 2006
RE: Focusing a window
I would use the "BringWindowToTop" function in the Win32 API to get the window to front.

And in this case I would test this if-statement instead:
code:
if(openwnd)
{
//stuff here
}
4 8 15 16 23 42
03-14-2008 10:24 PM
Profile E-Mail PM Find Quote Report
MeEtc
Patchou's look-alike
*****

Avatar
In the Shadow Gallery once again

Posts: 2200
Reputation: 60
38 / Male / Flag
Joined: Nov 2004
Status: Away
O.P. RE: Focusing a window
Still doesn't explain why openwnd.Handle is not defined
[Image: signature/]     [Image: sharing.png]
I cannot hear you. There is a banana in my ear.
03-14-2008 10:30 PM
Profile PM Web Find Quote Report
Spunky
Former Super Mod
*****

Avatar

Posts: 3658
Reputation: 61
35 / Male / Flag
Joined: Aug 2006
RE: Focusing a window
Yays, Fixed it :p
<Eljay> "Problems encountered: shit blew up" :zippy:
03-14-2008 10:58 PM
Profile PM Find Quote Report
MeEtc
Patchou's look-alike
*****

Avatar
In the Shadow Gallery once again

Posts: 2200
Reputation: 60
38 / Male / Flag
Joined: Nov 2004
Status: Away
O.P. RE: Focusing a window
I was setting openwnd to the wrong createwnd command :$
[Image: signature/]     [Image: sharing.png]
I cannot hear you. There is a banana in my ear.
03-14-2008 10:59 PM
Profile PM Web Find Quote Report
vikke
Senior Member
****

Avatar

Posts: 900
Reputation: 28
31 / Male / Flag
Joined: May 2006
RE: RE: Focusing a window
quote:
Originally posted by MeEtc
Still doesn't explain why openwnd.Handle is not defined
I have no idea of any other parts of your code, so it's impossible to know without guessing.
Anyway I'm glad it sorted out! :)
4 8 15 16 23 42
03-14-2008 11:13 PM
Profile E-Mail PM Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On