|  [help] destroying a window without crashing WLM | 
| Author: | 
Message: | 
Pai 
Full Member 
   
  
w00t !
  
Posts: 203 Reputation: 2 
– /   / – 
Joined: Sep 2003 
 | 
O.P.  [help] destroying a window without crashing WLM
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  
 |   
 | 
| 07-22-2006 04:37 PM | 
 | 
  | 
Mnjul 
forum super mod 
      
  
  
plz wub me
  
Posts: 5396 Reputation: 58 
– /   /   
Joined: Nov 2002
 
Status: Away
 
 | 
 RE: [help] destroying a window without crashing WLM
Er...I do see "Close" method in PlusWnd Object, in the scripting documentation    
 |   
 | 
| 07-22-2006 07:46 PM | 
 | 
  | 
Mike 
Elite Member 
     
  
  
Meet the Spam Family!
  
Posts: 2794 Reputation: 48 
33 /   /   
Joined: Mar 2003
 
Status: Online
 
 | 
 RE: [help] destroying a window without crashing WLM
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    
 |   
 | 
| 07-22-2006 07:48 PM | 
 | 
  | 
cooldude_i06 
Full Member 
   
  
  
I'm so cool I worry myself.
  
Posts: 272 Reputation: 9 
– /   / – 
Joined: Sep 2003 
 | 
 RE: [help] destroying a window without crashing WLM
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.   
 |   
 | 
| 07-22-2006 07:50 PM | 
 | 
  | 
Plik 
Veteran Member 
     
  
  
 
Posts: 1487 Reputation: 46 
36 /   / – 
Joined: Jun 2004 
 | 
| 
 RE: [help] destroying a window without crashing WLM
 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. 
 |   
 | 
| 07-22-2006 07:52 PM | 
 | 
  | 
Pai 
Full Member 
   
  
w00t !
  
Posts: 203 Reputation: 2 
– /   / – 
Joined: Sep 2003 
 | 
O.P.  RE: [help] destroying a window without crashing WLM
Yeah I should have said that it's not a PlusWnd that I want closed, but a conversation window one    Sorry 'bout that.
 
@ Plik: Thanks I'm gonna try it    
 |   
 | 
| 07-22-2006 07:59 PM | 
 | 
  | 
Aeryn 
Full Member 
   
  
  
 
Posts: 229 Reputation: 28 
– /   / – 
Joined: Jun 2005
 
Status: Away
 
 | 
 RE: [help] destroying a window without crashing WLM
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.  
 |   
 | 
| 07-22-2006 09:11 PM | 
 | 
  | 
Pai 
Full Member 
   
  
w00t !
  
Posts: 203 Reputation: 2 
– /   / – 
Joined: Sep 2003 
 | 
O.P.  RE: [help] destroying a window without crashing WLM
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   
 |   
 | 
| 07-23-2006 03:19 AM | 
 | 
  | 
Plan-1130 
Full Member 
   
  
I keep askin' myself: why?
  
Posts: 142 
74 /   / – 
Joined: Feb 2005 
 | 
| 
 RE: [help] destroying a window without crashing WLM
 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... 
 This post was edited on 11-16-2006 at 06:30 AM by Plan-1130.
 |   
 | 
| 10-14-2006 08:50 PM | 
 | 
  | 
| 
 |