What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » [?] Modal windows...

[?] Modal windows...
Author: Message:
whiz
Senior Member
****


Posts: 568
Reputation: 8
– / – / Flag
Joined: Nov 2008
O.P. Huh?  [?] Modal windows...
Just wondering if it's actually possible to make a Plus! window "attach" to another Plus! window, so that you have to close the modal one first (it is called modal, isn't it)...

Can't seem to find anything on MSDN...  :S
05-19-2010 06:38 PM
Profile E-Mail PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: [?] Modal windows...
Patchou's reply to Modal Windows
05-19-2010 06:51 PM
Profile E-Mail PM Find Quote Report
whiz
Senior Member
****


Posts: 568
Reputation: 8
– / – / Flag
Joined: Nov 2008
O.P. RE: [?] Modal windows...
If anyone's interested as to how to do it, this should work.
JScript code:
// make the parent window, make a variable for the child window
var WndParent = MsgPlus.CreateWnd("Interface.xml", "WndParent");
var WndChild = null;
 
// use any event here, this is just an example
function OnWndParentEvent_CtrlClicked(PlusWnd, ControlId)
{
    if (ControlId === "BtnConfirm")
    {
        // create the child, disable and monitor the parent
        WndChild = MsgPlus.CreateWnd("Interface.xml", "WndChild");
        Interop.Call("user32", "EnableWindow", WndParent.Handle, false);
        WndParent.RegisterMessageNotification(0x0006);
    }
}
 
// when the parent window is focused
function OnWndParentEvent_MessageNotification(PlusWnd, Message, wParam, lParam)
{
    if (wParam !== 0)
    {
        try
        {
            // focus the child window
            Interop.Call("user32", "SetFocus", WndChild.Handle);
            Interop.Call("user32", "BringWindowToTop", WndChild.Handle);
        }
        catch (error)
        {
        }
    }
}
 
function OnWndChildEvent_CtrlClicked(PlusWnd, ControlId)
{
    switch (ControlId)
    {
        case "BtnOk":
            // do whatever here, then close the child
            PlusWnd.Close(1);
            break;
    }
}
 
function OnWndChildEvent_Destroyed(PlusWnd, ExitCode)
{
    // enable and focus the child window
    Interop.Call("user32", "EnableWindow", WndParent.Handle, true);
    Interop.Call("user32", "SetFocus", WndParent.Handle);
}

XML code:
<Interfaces xmlns="urn:msgplus:interface" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:msgplus:interface PlusInterface.xsd">
 
<Window Id="WndParent" Version="1">
 
    <Attributes>
        <Caption>Modal Test</Caption>
    </Attributes>
 
    <TitleBar>
        <Title>
            <Prefix>Image</Prefix>
            <Text>Modal Test</Text>
        </Title>
    </TitleBar>
 
    <Position Width="300" Height="250">
        <IsAbsolute>true</IsAbsolute>
    </Position>
 
    <DialogTmpl/>
 
    <Controls>
        <Control xsi:type="CodeEditControl" Id="EdtCode">
            <Position Left="3" Top="0" Width="280" Height="171">
                <Units>AllPixels</Units>
            </Position>
        </Control>
        <Control xsi:type="ButtonControl" Id="BtnConfirm">
            <Position Left="3" Top="177" Width="70">
                <Units>AllPixels</Units>
            </Position>
            <Attributes>
                <IsDefault>true</IsDefault>
            </Attributes>
            <StandardLook Template="Blue"/>
            <Caption>&amp;Confirm...</Caption>
            <Help>Display the confirmation...</Help>
        </Control>
        <Control xsi:type="ButtonControl" Id="BtnCancel">
            <Position Left="228" Top="177" Width="55">
                <Units>AllPixels</Units>
            </Position>
            <Caption>&amp;Close</Caption>
            <Help>Close the window...</Help>
        </Control>
    </Controls>
 
</Window>
 
<Window Id="WndChild" Version="1">
 
    <Attributes>
        <Caption>Confirm?</Caption>
        <ShowInTaskbar>false</ShowInTaskbar>
    </Attributes>
 
    <TitleBar>
        <AllowMinimize>false</AllowMinimize>
        <AllowClose>false</AllowClose>
        <Title>
            <Prefix>Image</Prefix>
            <Text>Confirm?</Text>
        </Title>
    </TitleBar>
 
    <Position Width="120" Height="73">
        <IsAbsolute>true</IsAbsolute>
    </Position>
 
    <DialogTmpl/>
 
    <Controls>
        <Control xsi:type="ButtonControl" Id="BtnOk">
            <Position Left="2" Top="0" Width="40">
                <Units>AllPixels</Units>
            </Position>
            <StandardLook Template="Blue"/>
            <Caption>Ok</Caption>
        </Control>
        <Control xsi:type="ButtonControl" Id="BtnCancel">
            <Position Left="44" Top="0" Width="60">
                <Units>AllPixels</Units>
            </Position>
            <Caption>Cancel</Caption>
        </Control>
    </Controls>
 
</Window>
 
</Interfaces>


.plsc File Attachment: Modal Test.plsc (1.98 KB)
This file has been downloaded 124 time(s).

This post was edited on 05-20-2010 at 05:33 PM by whiz.
05-20-2010 05:28 PM
Profile E-Mail PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: [?] Modal windows...
This is the op of the thread I linked to. Not sure if it works in this scenario or not.

quote:
Originally posted by Dempsey
Is it possible to open a modal window in front of an existing window?

Eg I have my prefs window and the I open a smaller window.

I use EnableWindow to disable the main prefs window, but If I then switch to another program and then select the window in the taskbar, I just see the disabled Prefs window which i can't obviously do anything with, and as the other window is small it's hidden behind it.

How can I do it like for example the plus prefs do it when downloading script documentation etc, which keeps the mini-window on top even when switching to another program and back again.

Thanks for any ideas :)
05-20-2010 05:52 PM
Profile E-Mail PM Find Quote Report
whiz
Senior Member
****


Posts: 568
Reputation: 8
– / – / Flag
Joined: Nov 2008
O.P. RE: [?] Modal windows...
I have tried it by switching programs and then back again using the taskbar (and Atl+Tab), and they both seem to work.  Probably because mine focuses the child and brings it to the top.
05-20-2010 07:09 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