What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Prevent closing chats?

Pages: (2): « First « 1 [ 2 ] Last »
Prevent closing chats?
Author: Message:
Jesus
Scripting Contest Winner
****

Avatar
Koffie, my cat ;)

Posts: 623
Reputation: 15
38 / Male / Flag
Joined: Jul 2005
O.P. RE: Prevent closing chats?
Am I right that dscwpmsg.dll from this thread can do what I want?
I've tried some stuff with it, but I can't figure out what does and does not work :(
08-26-2006 12:46 PM
Profile PM Find Quote Report
Jesus
Scripting Contest Winner
****

Avatar
Koffie, my cat ;)

Posts: 623
Reputation: 15
38 / Male / Flag
Joined: Jul 2005
O.P. RE: Prevent closing chats?
*bump*

anyone?
09-09-2006 03:22 PM
Profile PM Find Quote Report
Delphi Thunderbolt
Junior Member
**

Avatar
The insane developer

Posts: 53
Reputation: 1
35 / Male / –
Joined: Sep 2004
RE: Prevent closing chats?
It would be better if you looked for the API message that closes the window (Most likely WM_NCCLOSE) and cancel it out.

That would be your best bet, as nothing would be able to close the window while your script intercepts and terminates this message.

I grabbed this from a Delphi forum, which you could probably use in a DLL and call the function from your script. Take note of the bolded pieces of code.

code:
procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
var
answer : string;
begin
answer := InputBox('Admin password?','password', '');
if answer='yourpassword' then canclose:=true
else
canclose:=false;
end;


Like I said before, it's not going to be easy initially, but it's quite easy to understand and it's well worth the effort.
[Image: thundtacuserbar.gif]

It's my freedom, it's my duty, it's my war.

The day will go dark and quiet as the mighty Thunderbolts announce the end of the world...
09-10-2006 01:41 AM
Profile E-Mail PM Web Find Quote Report
Jesus
Scripting Contest Winner
****

Avatar
Koffie, my cat ;)

Posts: 623
Reputation: 15
38 / Male / Flag
Joined: Jul 2005
O.P. RE: Prevent closing chats?
Well the message to be cancelled is WM_DESTROY, which I found using Winspector Spy. So I went looking for a way to hook the chat window. I found the mentioned thread and started looking into it.
In the included textfile I found a function to discard specific messages, which I believe is what I'm looking for (please tell me if I'm wrong).

problem is, when I try to hook the message window using
code:
    Interop.Call(MsgPlus.ScriptFilesPath + "\\dscwpmsg.dll", "SetCWPMSGHook", ChatWnd.Handle, 1, 1)

it returns 0...
quote:
dscwpmsg.txt
Return Value:

2, if both of the Hooks were installed rsp. released successfully,
1, if one of the Hooks was installed rsp. released successfully,
0 (Zero) otherwise.

.txt File Attachment: dscwpmsg.txt (6.99 KB)
This file has been downloaded 264 time(s).
09-10-2006 11:01 AM
Profile PM Find Quote Report
Plik
Veteran Member
*****

Avatar

Posts: 1489
Reputation: 46
35 / Male / –
Joined: Jun 2004
RE: Prevent closing chats?
quote:
Originally posted by Jesus
Well the message to be cancelled is WM_DESTROY
You probably want to cancel WM_CLOSE and not WM_DESTROY ;)
Because WM_CLOSE is the message that is sent to a window to tell it to start closeing, and this lets the window clean up and do anything it needs todo when its closed (for example in a group conversation it shows the prompt dialog when you send WM_CLOSE).
However WM_DESTROY is what is sent when the window actually needs to be destroyed, usually after WM_CLOSE has been sent, and the window has had time to clean up.

So if you only canceled WM_DESTROY then the window would still do all the closeing it needs todo (like ending sessions) but the window would just never get destroyed. So you need to possible cancel both.
Hope this makes some sense :)
09-10-2006 11:26 AM
Profile PM Find Quote Report
Jesus
Scripting Contest Winner
****

Avatar
Koffie, my cat ;)

Posts: 623
Reputation: 15
38 / Male / Flag
Joined: Jul 2005
O.P. RE: Prevent closing chats?
that makes sense indeed, the only problem is that I don't see any WM_CLOSE messages in the window's message list (screenshot)

.jpg File Attachment: winspy.jpg (181.74 KB)
This file has been downloaded 199 time(s).
09-10-2006 11:59 AM
Profile PM Find Quote Report
xxhannahxx
Junior Member
**

Avatar
Previously known as xx134xx

Posts: 19
Reputation: -2
30 / Female / –
Joined: Sep 2006
RE: Prevent closing chats?
i know someone that could make this for you probally
09-10-2006 12:30 PM
Profile E-Mail PM Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15517
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: Prevent closing chats?
jesus, there are many different kind of hooks and methods. And for each specific thing you want to do you need different kinds and different approaches. You can't base your code on some listing which does something completely different (refering to the thread you listed).


What you in the first place need to prevent closing of a window is subclassing. You need to trap WM_CLOSE in the window's windows messages stream.

This means that you will need to redirect the windows messages stream (often called the 'WindowProc') to a function in your program (note: this can not be done in JScript) with a callback function.

In that callback function you simply pass thru all the messages the window will recieve (which are a massive load) to the default WindowProc. Only when WM_CLOSE is detected your callback function must not do anything and thus will effectivly cancel this windows message out.

To subclass a window all you need to do is to change its main window proc address to the address of your callback function so that is called instead. (and in your callback procedure calls the original windowproc procedure of the Window).

An easy (VB6) example explaning all this: http://www.osix.net/modules/article/?id=653



However, you probably also need a system wide or application wide hook to know when a window is opened, so you can get its handle and subclass it. (you could also use a timed loop for this to poll for any newly opened windows, so you don't need a hook at all, but that is rather a more crappy way of doing it imho).

Or if you're writing a DLL to be loaded in a Plus! script, you can of course simply use the Plus! scripting event ChatWndCreated to pass the handle of the chat window to your DLL which on its turn subclass that chat window.

quote:
Originally posted by Delphi Thunderbolt
I grabbed this from a Delphi forum, which you could probably use in a DLL and call the function from your script. Take note of the bolded pieces of code.
That code actually doesn't help at all or has not much todo with this. The code is a build-in event in Delphi and many more languages to trap the closing of a window which was created by that same code. No hooking involved at all. you can't use it, nor any parts of this.

This post was edited on 09-10-2006 at 03:15 PM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
09-10-2006 03:00 PM
Profile PM Find Quote Report
Delphi Thunderbolt
Junior Member
**

Avatar
The insane developer

Posts: 53
Reputation: 1
35 / Male / –
Joined: Sep 2004
RE: Prevent closing chats?
Yeah, sorry there. Just realised it after re-reading the code.

It may be useful to someone, somewhere so Ill leave it.
[Image: thundtacuserbar.gif]

It's my freedom, it's my duty, it's my war.

The day will go dark and quiet as the mighty Thunderbolts announce the end of the world...
09-11-2006 10:38 AM
Profile E-Mail PM Web Find Quote Report
Jesus
Scripting Contest Winner
****

Avatar
Koffie, my cat ;)

Posts: 623
Reputation: 15
38 / Male / Flag
Joined: Jul 2005
O.P. RE: Prevent closing chats?
thanks for the replies, I know a bit of VB programming so I'll try it with the help of the links and info you all provided me.
09-11-2006 05:33 PM
Profile PM Find Quote Report
Pages: (2): « First « 1 [ 2 ] Last »
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On