Shoutbox

[Help] Windows close button - 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: [Help] Windows close button (/showthread.php?tid=74563)

[Help] Windows close button by DarkGhost on 05-21-2007 at 01:10 AM

Hello I am pretty new at Scripting but I made a window  and the close button doesnt work, code for the window is


code:
<?xml version="1.0" encoding="UTF-16"?>
<Interfaces xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">   
<Window Id="schange" Version="1">       
<Attributes>           
<Caption>You Changed Ur Shit!!</Caption>
        </Attributes>
        <TitleBar>
            <Title><Text>Ello mate</Text></Title>
        </TitleBar>
        <Position Width="180" Height="75" Left="100"/>
        <DialogTmpl/>
        <Controls>
            <Control xsi:type="StaticControl" Id="LblTop">
                <Position Left="10" Top="10" Width="150"/>
                <Caption>You changed ur status</Caption>
            </Control>
            <Control xsi:type="ButtonControl" Id="BtnClose">
                <Position Left="112" Top="25" Width="50"/>               
<Caption>Close</Caption>
            </Control>
        </Controls>
    </Window>
</Interfaces>
and for windows live script it is:
code:
function OnEvent_Initialize(MessengerStart)
{
}

function OnEvent_Uninitialize(MessengerExit)
{
}
function OnEvent_MyStatusChange()
{
var Wnd = MsgPlus.CreateWnd("InterfaceTest.xml", "schange");
}
function OnWndTestEvent_CtrlClicked(Wnd, ControlId)
{
Debug.Trace("Hello World!");
if(ControlId == "BtnClose") Wnd.Close(1); Debug.Trace("woot");

}

main point is the close  button doesnt work :( WHYY!
RE: [Help] Windows close button by matty on 05-21-2007 at 03:05 AM

Change the bolded part to "BtnCancel"

code:
            <Control xsi:type="ButtonControl" Id="BtnClose">
                <Position Left="112" Top="25" Width="50"/>               
<Caption>Close</Caption>

BtnCancel is built into Messenger Plus! Live Scripting that when clicked it will close the window.



Or with your code

code:
function OnWndTestEvent_CtrlClicked(Wnd, ControlId) {
    Debug.Trace("Hello World!");
    if(ControlId == "BtnClose"){
        Debug.Trace("woot");
        Wnd.Close(0);
    }
}

Or with the Windows API

code:
var WM_CLOSE = 0x10;
function OnWndTestEvent_CtrlClicked(Wnd, ControlId) {
    Debug.Trace("Hello World!");
    if(ControlId == "BtnClose"){
        Debug.Trace("woot");
        Interop.Call('user32', 'SendMessageW', Wnd.Handle, WM_CLOSE, 0, 0);
    }
}

RE: RE: [Help] Windows close button by CookieRevised on 05-21-2007 at 04:12 AM

* CookieRevised slaps Matty around a bit with a wet trout (my turn to slap now :p)



quote:
Originally posted by Matty
Change the bolded part to "BtnCancel"
code:
<Control xsi:type="ButtonControl" Id="BtnClose">
      <Position Left="112" Top="25" Width="50"/>               
<Caption>Close</Caption>
BtnCancel is built into Messenger Plus! Live Scripting that when clicked it will close the window.
nevertheless, the button should work, no matter what you named it, as long as you use the same id in the script...

So this isn't the error he has made... it was correct what he did...



quote:
Originally posted by Matty
Or with your code
code:
function OnWndTestEvent_CtrlClicked(Wnd, ControlId) {
    Debug.Trace("Hello World!");
    if(ControlId == "BtnClose"){
        Debug.Trace("woot");
        Wnd.Close(0);
    }
}

It doesn't matter what parameter you give to the Close() function. The parameter is a custom exit code which you can define whatever you want.

So this isn't the error he has made... it was correct what he did...



quote:
Originally posted by Matty
Or with the Windows API
code:
var WM_CLOSE = 0x10;
function OnWndTestEvent_CtrlClicked(Wnd, ControlId) {
    Debug.Trace("Hello World!");
    if(ControlId == "BtnClose"){
        Debug.Trace("woot");
        Interop.Call('user32', 'SendMessageW', Wnd.Handle, WM_CLOSE, 0, 0);
    }
}

Even with this code it will still not work...

because:

quote:
Originally posted by DarkGhost
function OnEvent_MyStatusChange()
{
     var Wnd = MsgPlus.CreateWnd("InterfaceTest.xml", "schange");
}
function OnWndTestEvent_CtrlClicked(Wnd, ControlId)
{
     Debug.Trace("Hello World!");
     if(ControlId == "BtnClose") Wnd.Close(1);
     Debug.Trace("woot");
}

He forgot to change the name of the window id in the event function name which he took from the example in the scripting documentation.

The event function must be:
function OnschangeEvent_CtrlClicked(Wnd, ControlId)


;)

* CookieRevised goes to sleep now too...
RE: RE: RE: [Help] Windows close button by Volv on 05-21-2007 at 11:27 AM

Sorry Cookie, but Matty is right this time... btnCancel is coded into MsgPlus to automatically close the window without requiring any script code, and this is the easiest way to do it.

EDIT: But I suppose correcting his event code is useful too :p


RE: [Help] Windows close button by CookieRevised on 05-21-2007 at 11:31 AM

quote:
Originally posted by Volv
Sorry Cookie, but Matty is right this time... btnCancel is coded into MsgPlus to automatically close the window without requiring any script code, and this is the easiest way to do it.
I never said he was wrong with the btnCancel being a build-in id, I even confirmed it. (I said "nevertheless, blahblah"). But, that is not the mistake DarkGhost has made.

I said it doesn't matter what you name the button as long as you use the same id in the script itself. You can use whatever name you like, including for a close button. The only thing you wont have is the auto-closing when you click and you need to code it yourself, just as DarkGhost did. DarkGhost didn't do anything wrong there.

The close button didn't worked because he named his event function wrong. All the other code, including the xml, is correct code.

;)
RE: [Help] Windows close button by DarkGhost on 05-21-2007 at 07:38 PM

well thank you now i know where to come for from help :) also what would be the code to make it do something like when you type /blah or something happenmdds


RE: [Help] Windows close button by CookieRevised on 05-23-2007 at 01:12 AM

quote:
Originally posted by DarkGhost
also what would be the code to make it do something like when you type /blah or something happenmdds
only one topic per thread, otherwise it gets too chaotic... As for your question, see your other thread: "Gettin data from "/" commands".





RE: [Help] Windows close button by DarkGhost on 05-23-2007 at 01:15 AM

quote:
Originally posted by CookieRevised
quote:
Originally posted by DarkGhost
also what would be the code to make it do something like when you type /blah or something happenmdds
only one topic per thread, otherwise it gets too chaotic... As for your question, see your other thread: "Gettin data from "/" commands".
ya thanks i got that just a few mins ago