Shoutbox

[?] Stop the X button from closing a PlusWnd - 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: [?] Stop the X button from closing a PlusWnd (/showthread.php?tid=64778)

[?] Stop the X button from closing a PlusWnd by Matti on 08-11-2006 at 09:03 AM

Hello again! :P

Countdown Live is almost ready to rock! Now I need some help again...
As you know, a PlusWnd has a close button in the top right corner. When you click it, it'll close the window. I now want to stop it closing the window and display a confirmation box if the user really wants to close the window without saving the changes first. When the user chooses Yes, it'll close the window. When the user chooses No, the window has to stay open.
Now, how the hell should I do that?! :S

code:
Code for the box
//PlusWnd is the options window. (duh)
//"Language.WndOptions['CloseConfirm']" is a string containing the question.
var result = Interop.Call('User32', 'MessageBoxW', PlusWnd.Handle, Language.WndOptions['CloseConfirm'], 'Countdown Live', 0x42124);
if(result == 6) { //Yes
    //Close window
} else { //No
    //Don't close!!!
}

Thanks in advance! ;)
RE: [?] Stop the X button from closing a PlusWnd by Mike on 08-11-2006 at 09:07 AM

If I remember correctly, there is a "Cancel" parameter that tells if the window should close or not.
I'm looking into it...


RE: [?] Stop the X button from closing a PlusWnd by Ash_ on 08-11-2006 at 09:18 AM

code:
function OnSong2AvatarEvent_CtrlClicked(PlusWnd, ControlId){
if(ControlId == 'BaseBtnCancel') {
MsgPlus.CancelTimer("CheckSong");
}
}


is what i use to check if they click the x button, then if they do it cancels my timer, simply change my cancel timer call to wahtever you need (I'd do it myself but i can't be bothered :P)
RE: [?] Stop the X button from closing a PlusWnd by Matti on 08-11-2006 at 01:47 PM

That did the trick! :D Never knew there was such special control id available! :)

Thanks all! ;)


RE: [?] Stop the X button from closing a PlusWnd by deAd on 08-11-2006 at 02:42 PM

Or, in the OnWndDestroyed thingy or whatever, just return true to cancel the event :) much easier

EDIT: There's also an XML attribute that lets you remove the box also.


RE: [?] Stop the X button from closing a PlusWnd by matty on 08-11-2006 at 02:48 PM

code:
function OnWndCountDownDisplayEvent_Destroyed(Wnd, nExitCode){
    if (TimerLength > 1){
        OnWndCountDownDisplayEvent_Cancel = true;
    }
}
   
function OnWndCountDownDisplayEvent_Cancel(Wnd){
    if (TimerLength > 1){
        return true;
    }
}


That is how I do it on Screenshot Sender 4. Remember that TimerLength is the TimerCountdown included in the program. This will also prevent the user from pressing the Esc key on the keyboard to close the window.