[?] Modal windows... - 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: [?] Modal windows... (/showthread.php?tid=94617)
[?] Modal windows... by whiz on 05-19-2010 at 06:38 PM
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...
RE: [?] Modal windows... by matty on 05-19-2010 at 06:51 PM
Patchou's reply to Modal Windows
RE: [?] Modal windows... by whiz on 05-20-2010 at 05:28 PM
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>&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>&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>
RE: [?] Modal windows... by matty on 05-20-2010 at 05:52 PM
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
RE: [?] Modal windows... by whiz on 05-20-2010 at 07:09 PM
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.
|