Shoutbox

Debug Please - 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: Debug Please (/showthread.php?tid=80486)

Debug Please by ::Quick:: on 12-28-2007 at 12:28 PM

Hi,

I was wondering if someone could please debug a function.

Simply when a message is received, it's supposed to say Test and close the chat window, except it just keeps on sending the same test message every second and it does not close the window.

code:
function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind)
{
ChatWnd.SendMessage("Test");
PlusWnd.Close(0);
}

RE: Debug Please by Mnjul on 12-28-2007 at 12:48 PM

You need to send the message only when the Origin is not you.

The easiest way to close a chat window is to send "/close" message; alternatively you can call PostMessageW to post WM_CLOSE. Anyway, why did you use PlusWnd? :S


RE: Debug Please by Matti on 12-28-2007 at 12:59 PM

As Mnjul said, you made 2 mistakes:

  • OnEvent_ChatWndReceiveMessage is also called for messages you sent and are "received" in the chat window. Therefore, you should check the Origin: only if the Origin is not your own name, you should send the message "Test".
  • The Close() function is a child of the PlusWnd object. PlusWnds have absolutely nothing to do with ChatWnds. Therefore, the Close() method won't work for a ChatWnd object. The easiest way to close the window then is to send "/close", after checking if you can actually send something by checking if ChatWnd.EditChangeAllowed is true, but in fact you should do that before you send your "Test" message.
Hopefully these hints allow you to fix your problem. :)