Shoutbox

[help] destroying a window without crashing WLM - 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] destroying a window without crashing WLM (/showthread.php?tid=63794)

[help] destroying a window without crashing WLM by Pai on 07-22-2006 at 04:37 PM

I'm trying to destroy a window through the API (plus doesn't offer functions to do this), but either instantly or soner or later WLM crashes ...

I can hide/show windows, close them (this doesn't destroy them, just sorta minimizes them) and everything works fine.

code:
Hiding:
Interop.Call('user32','ShowWindow',Wnd.Handle, 0);

Showing:
Interop.Call('user32','ShowWindow',Wnd.Handle, 1);

Close(minimize):
Interop.Call('user32','CloseWindow',Wnd.Handle);

Destroy:
Interop.Call('user32','DestroyWindow',Wnd.Handle);

According to MSDN this is correct ...

Any ideas ?

Thanks
RE: [help] destroying a window without crashing WLM by Mnjul on 07-22-2006 at 07:46 PM

Er...I do see "Close" method in PlusWnd Object, in the scripting documentation :)


RE: [help] destroying a window without crashing WLM by Mike on 07-22-2006 at 07:48 PM

quote:
Originally posted by Mnjul
Er...I do see "Close" method in PlusWnd Object, in the scripting documentation :)
I don't think he wants to destroy a PlusWnd object, but I think he wants to destroy a window, other a window created by his script :)
RE: [help] destroying a window without crashing WLM by cooldude_i06 on 07-22-2006 at 07:50 PM

The PlusWnd::Close function destroys the window.

Syntax

code:
Close(
    [number] ExitCode
);
Parameters
ExitCode
[number] A number specifying the exit code for the window. It has no particular meaning for Messenger Plus! and can be anything the script's developer wishes it to be.
RE: [help] destroying a window without crashing WLM by Plik on 07-22-2006 at 07:52 PM

If you want to close a window that isn't created by your script, then the correct way would be to send it a WM_CLOSE message.
This lets it tidy up, and do anything it needs to before closing, however is you destroy the window straight away, it can't finish what it was doing, and quite often causes some crashing.


RE: [help] destroying a window without crashing WLM by Pai on 07-22-2006 at 07:59 PM

Yeah I should have said that it's not a PlusWnd that I want closed, but a conversation window one :P Sorry 'bout that.

@ Plik: Thanks I'm gonna try it :)


RE: [help] destroying a window without crashing WLM by Aeryn on 07-22-2006 at 09:11 PM

Try:

code:
Interop.Call("User32", "SendMessageW", Wnd.Handle, 0x10, 0, 0);

0x10 is WM_CLOSE.

If that doesn't work then try SendMessage instead of SendMessageW.

Sometimes even this method crashes WLM though, but I'm not sure why. It should make the window do exactly what would happen if you pressed the X button.
RE: [help] destroying a window without crashing WLM by Pai on 07-23-2006 at 03:19 AM

I couldn't use WM_CLOSE directly (didn't work here), but I found this workaround that is working as expected:

code:
Interop.Call('user32','SendMessageW',wnd.Handle, 0x0112, 0xF060, 0)
0x0112 for system command
0xF060 for close

Thanks all
RE: [help] destroying a window without crashing WLM by Plan-1130 on 10-14-2006 at 08:50 PM

Even that last one crashes wlm...
Try using PostMessageW, instead of SendMessageW.
This will, unlike SendMessageW, not wait for the message to be processed, don't ask me why it works, but it does...