HELP - Child Windows! |
Author: |
Message: |
whiz
Senior Member
Posts: 568 Reputation: 8
– / – /
Joined: Nov 2008
|
O.P. HELP - Child Windows!
Whenever I make a child window, like these:
js code: MsgPlus.CreateChildWnd("WndBrowser", "Windows.xml", "WndSearch", "100", "100", true);
MsgPlus.CreateChildWnd("WndBrowser", "Windows.xml", "WndSearch", 100, 100, true);
MsgPlus.CreateChildWnd("WndBrowser", "Windows.xml", "WndSearch", "100", "100");
MsgPlus.CreateChildWnd("WndBrowser", "Windows.xml", "WndSearch", 100, 100);
I get an error in the Script Debugger, saying "type mismatch". How come?
|
|
02-22-2009 04:50 PM |
|
|
Matti
Elite Member
Script Developer and Helper
Posts: 1646 Reputation: 39
32 / /
Joined: Apr 2004
|
RE: HELP - Child Windows!
quote: Originally posted by whiz
How come?
You are passing a string "WndBrowser" as first parameter, where the script documentation clearly says:
quote: Parent: [object] Existing PlusWnd object previously created with CreateWnd.
So, a valid example would be:
js code: //The parent window
var pBrowser = MsgPlus.CreateWnd("Windows.xml", "WndBrowser");
//The child window
var pSearch = MsgPlus.CreateChildWnd(pBrowser, "Windows.xml", "WndSearch", 100, 100);
As you can see, we're passing pBrowser (the created PlusWnd object) as first parameter. The reason why Plus! works this way is since you could make multiple instances of the same interface XML definition.
|
|
02-22-2009 05:21 PM |
|
|
whiz
Senior Member
Posts: 568 Reputation: 8
– / – /
Joined: Nov 2008
|
O.P. RE: HELP - Child Windows!
So I have to store the parent window into a variable?
|
|
02-23-2009 07:27 PM |
|
|
matty
Scripting Guru
Posts: 8336 Reputation: 109
39 / /
Joined: Dec 2002
Status: Away
|
RE: HELP - Child Windows!
Yes that is what he said...
|
|
02-23-2009 07:28 PM |
|
|
whiz
Senior Member
Posts: 568 Reputation: 8
– / – /
Joined: Nov 2008
|
O.P. RE: HELP - Child Windows!
Well, it still doesn't appear to be working. Am I still missing something?
js code: // if a menu item is clicked
function OnEvent_MenuClicked(sMenuId, nLocation, iOriginWnd)
{
if(sMenuId == "start")
{
if (OpenWnd) // checks for another instance of the browser
{
Debug.Trace("> Detected OpenWnd: " + OpenWnd)
Debug.Trace("> No more windows allowed!")
MsgPlus.CreateWnd("Windows.xml", "WndMaximum", 0)
// creates a warning alert window
}
else
{
Debug.Trace("> Detected OpenWnd: " + OpenWnd);
Debug.Trace("> Window allowed!");
Wnd = MsgPlus.CreateWnd("Windows.xml", "WndBrowser", 0);
// creates a browser window (variable 'Wnd')
OpenWnd = true;
Browser = Wnd.Browser_GetInterface("Browser");
Browser.GoHome();
}
}
js code: // if a browser button is clicked
function OnWndBrowserEvent_CtrlClicked(objWnd, strControlId)
{
switch(strControlId)
{
case "BtnSearch": // if the search button is clicked
SearchWnd = MsgPlus.CreateChildWnd(Wnd, "Windows.xml", "WndSearch", 100, 100);
// creates a child window (parent = 'Wnd')
break;
}
}
I have also tried putting your code in, exactly how it was, but only the main window appeared - the child window just didn't appear...
This post was edited on 02-23-2009 at 07:47 PM by whiz.
|
|
02-23-2009 07:46 PM |
|
|
matty
Scripting Guru
Posts: 8336 Reputation: 109
39 / /
Joined: Dec 2002
Status: Away
|
RE: HELP - Child Windows!
Is your variable Wnd globally defined?
And why not do this...
js code: // if a browser button is clicked
function OnWndBrowserEvent_CtrlClicked(objWnd, strControlId)
{
switch(strControlId)
{
case "BtnSearch": // if the search button is clicked
>>> SearchWnd = MsgPlus.CreateChildWnd(objWnd, "Windows.xml", "WndSearch", 100, 100);<<<
// creates a child window (parent = 'Wnd')
break;
}
}
This post was edited on 02-23-2009 at 07:58 PM by matty.
|
|
02-23-2009 07:56 PM |
|
|
whiz
Senior Member
Posts: 568 Reputation: 8
– / – /
Joined: Nov 2008
|
O.P. RE: RE: HELP - Child Windows!
quote: Originally posted by matty
Is your variable Wnd globally defined?
It is, but I have tried it without, and it still won't do anything.
quote: Originally posted by matty
And why not do this...js code: // if a browser button is clicked
function OnWndBrowserEvent_CtrlClicked(objWnd, strControlId)
{
switch(strControlId)
{
case "BtnSearch": // if the search button is clicked
>>> SearchWnd = MsgPlus.CreateChildWnd(objWnd, "Windows.xml", "WndSearch", 100, 100);<<<
// creates a child window (parent = 'Wnd')
break;
}
}
Doesn't make any difference...
|
|
02-23-2009 08:04 PM |
|
|
matty
Scripting Guru
Posts: 8336 Reputation: 109
39 / /
Joined: Dec 2002
Status: Away
|
RE: HELP - Child Windows!
Post the XML of your window.
matty's reply to Cannot CreateChildWnd
xml code: <!-- The child window -->
<Window Id="WndChildExample" Version="1">
<ChildTmpl/>
<Position Width="243" Height="193"/>
<Controls>
<Control xsi:type="StaticControl" Id="lblTitle">
<Position Top="25" Width="100" Left="15" Height="15" />
<Caption>hi I am a child window :)</Caption>
</Control>
</Controls>
</Window>
|
|
02-23-2009 08:08 PM |
|
|
whiz
Senior Member
Posts: 568 Reputation: 8
– / – /
Joined: Nov 2008
|
O.P. RE: HELP - Child Windows!
xml code: <!-- Browser Window -->
<Window Id="WndBrowser" Version="1">
<Attributes>
<Caption>Plus! Browser</Caption>
</Attributes>
<TitleBar>
<AllowMaximize>true</AllowMaximize>
<Title>
<Prefix>Image</Prefix>
<Text>Plus! Browser</Text>
</Title>
</TitleBar>
<Position Width="500" Height="400">
<IsAbsolute>true</IsAbsolute>
<Resizeable Allowed="BothSides">
<MinWidth>500</MinWidth>
<MinHeight>400</MinHeight>
</Resizeable>
</Position>
<DialogTmpl>
</DialogTmpl>
<Controls>
<Control xsi:type="ButtonControl" Id="BtnBack">
<Position Left="5" Top="1" Width="15"/>
<Image><Name>Back</Name></Image>
<Help>Back</Help>
</Control>
<Control xsi:type="ButtonControl" Id="BtnForward">
<Position Left="20" Top="1" Width="15"/>
<Image><Name>Forward</Name></Image>
<Help>Forward</Help>
</Control>
<Control xsi:type="ButtonControl" Id="BtnStop">
<Position Left="35" Top="1" Width="15"/>
<Image><Name>Cross</Name></Image>
<Help>Stop</Help>
</Control>
<Control xsi:type="ButtonControl" Id="BtnRefresh">
<Position Left="50" Top="1" Width="15"/>
<Image><Name>Refresh</Name></Image>
<Help>Refresh</Help>
</Control>
<Control xsi:type="ButtonControl" Id="BtnHome">
<Position Left="65" Top="1" Width="15"/>
<Caption>H</Caption>
<Help>Home</Help>
</Control>
<Control xsi:type="ButtonControl" Id="BtnSearch">
<Position Left="80" Top="1" Width="15"/>
<Image><Name>Find</Name></Image>
<Help>Search</Help>
</Control>
<Control xsi:type="ButtonControl" Id="BtnGo">
<Position Left="102" Top="1" Width="30"/>
<Caption>&Go to:</Caption>
</Control>
<Control xsi:type="EditControl" Id="EdtAddress">
<Position Left="199" Top="3" Width="281">
<Anchor Horizontal="LeftRightFixed"/>
<Units>AllPixels</Units>
</Position>
<Attributes><IsDefault>true</IsDefault></Attributes>
<Help>Enter a web address or file path...</Help>
</Control>
<Control xsi:type="StaticControl" Id="TxtCurrentPage">
<Transparency>100</Transparency>
<Position Left="8" Top="30" Width="470">
<Anchor Horizontal="LeftRightFixed"/>
<Units>AllPixels</Units>
</Position>
<Caption>Current address:</Caption>
</Control>
<Control xsi:type="BrowserControl" Id="Browser">
<Position Left="8" Top="55" Width="470" Height="290">
<Anchor Horizontal="LeftRightFixed" Vertical="TopBottomFixed"/>
<Units>AllPixels</Units>
</Position>
</Control>
</Controls>
</Window>
<!-- Search Popup -->
<Window Id="WndSearch" Version="1">
<ChildTmpl/>
<Attributes>
<Caption>Plus! Browser: Search...</Caption>
</Attributes>
<TitleBar>
<AllowMinimize>false</AllowMinimize>
<Title>
<Prefix>Image</Prefix>
<Text>Plus! Browser: Search...</Text>
</Title>
</TitleBar>
<Position Width="400" Height="150">
<IsAbsolute>true</IsAbsolute>
</Position>
<DialogTmpl>
<BottomBar Style="Plain">
<RightControls>
<Control xsi:type="ButtonControl" Id="BtnSearchGoogle">
<Position Left="292" Top="2" Width="55"/>
<Image><Name>Find</Name></Image>
<Caption>&Google</Caption>
</Control>
<Control xsi:type="ButtonControl" Id="BtnSearchYahoo">
<Position Left="292" Top="2" Width="55"/>
<Image><Name>Find</Name></Image>
<Caption>&Yahoo</Caption>
</Control>
<Control xsi:type="ButtonControl" Id="BtnCancel">
<Position Left="292" Top="2" Width="55"/>
<Image> <Name>Cross</Name></Image>
<Caption>&Cancel</Caption>
</Control>
</RightControls>
</BottomBar>
</DialogTmpl>
<Controls>
<Control xsi:type="StaticControl" Id="InfoTxt">
<Position Left="8" Top="3" Width="370">
<Anchor Horizontal="LeftRightFixed"/>
<Units>AllPixels</Units>
</Position>
<Attributes>
<IsDefault>true</IsDefault>
</Attributes>
<Caption>Enter the text to search for, and click Search to open a results window.</Caption>
</Control>
<Control xsi:type="EditControl" Id="EdtSearch">
<Position Left="8" Top="23" Width="370">
<Anchor Horizontal="LeftRightFixed"/>
<Units>AllPixels</Units>
</Position>
<Attributes>
<IsDefault>true</IsDefault>
</Attributes>
<Help>Enter a search query...</Help>
</Control>
</Controls>
</Window>
|
|
02-23-2009 08:21 PM |
|
|
matty
Scripting Guru
Posts: 8336 Reputation: 109
39 / /
Joined: Dec 2002
Status: Away
|
RE: HELP - Child Windows!
Your XML is invalid for your child window. You cannot have a <ChildTmpl /> and a <DialogTmpl /> at the same time as they signify different appearences for the windows.
This post was edited on 02-23-2009 at 08:29 PM by matty.
|
|
02-23-2009 08:29 PM |
|
|
Pages: (3):
« First
[ 1 ]
2
3
»
Last »
|
|