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.