One would assume that by subclassing the Chat Window and ignoring the WM_CLOSE message unless you were to type /close then that should work.
Obviously someone would need to write a DLL to subclass the windows but in theory the aforementioned pseudo should suffice for the situation.
If anyone wants to try the code out that I wrote by all means
Please note the following:
- It is not recommended to do asynchronous callbacks in Plus! as the potential for collisions and crashes is higher
- To my knowledge this has never been attempted and I posted without testing and therefore this could cause WLM to crash. Use at your own risk.
- This is also only for testing purposes to see if my theory works.
(Which as I am writing this it may not because your sent messages will show on both computers therefore typing /close will not work.)(I updated the code to close the Chat Window only when pressing the Escape key. This should prevent the other Chat Window from closing as well.)
js code:
/* Define object container */
var pChats = {};
/* Define script constants */
var WM_CLOSE = 0x0010;
var WM_KEYDOWN = 0x100;
var GWL_WNDPROC = (-4);
var VK_ESC = 0x11b;
/* Called when a Chat Window is created */
function OnEvent_ChatWndCreated(oChatWnd) {
Subclass_ChatWnd(oChatWnd);
}
/* Called after we process the WM_CLOSE message */
function OnEvent_ChatWndDestroyed(oChatWnd) {
Interop.Call('user32', 'SetWindowLongPtrW', pChat.Handle, GWL_WNDPROC, pChats[oChatWnd.Handle].WindowLongPtr);
delete pChats[oChatWnd.Handle];
}
/* Called when a chat window is created to assign values to the object container */
function Subclass_ChatWnd(pChat) {
pChats[pChat.Handle] = {
ChatWnd : pChat,
WindowLongPtr : Interop.Call('user32', 'GetWindowLongPtrW', pChat.Handle, GWL_WNDPROC),
AllowClose : false
}
Interop.Call('user32', 'SetWindowLongPtrW', pChat.Handle, GWL_WNDPROC, Interop.GetCallbackPtr('CALLBACK'));
}
/* CALLBACK function */
function CALLBACK (hWnd, nMsg, wParam, lParam) {
switch (nMsg) {
case WM_CLOSE:
if (pChats[hWnd].AllowClose === false) {
return -1;
}
break;
case WM_KEYDOWN:
if (wParam === VK_ESC) {
pChats[hWnd].AllowClose = true;
}
}
Interop.Call('user32', 'DefWindowProcW', hWnd, nMsg, wParam, lParam);
}