What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Help with SendMessage()

Help with SendMessage()
Author: Message:
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: Help with SendMessage()
The reason it isn't making sense is because you are not globally defining the Chat Window object. You could do this by putting var objChatWnd; at the top of your script then in your OnEvent_MenuClicked you would assign objChatWnd = pChatWnd. The problem then becomes how do you support multiple windows. Well you would do that with the following code. Let me know if this doesn't make sense.

js code:
// Object container
var oChatWnds = {};

// We clicked a menu item, let us make sure it is from the chat window
function OnEvent_MenuClicked(sMenuItemId, nLocation, pChatWnd) {
    if (nLocation === MENULOC_CHATWND) {
        // Create the window
        var tmpWindow = MsgPlus.CreateWnd('TestXmlFile.xml', 'TestWindow');
        // Store the Chat Window object in a container
        oChatWnds[tmpWindow.Handle] = pChatWnd;
    }
}

// We pushed a button
function OnTestWindowEvent_CtrlClicked(pPlusWnd, sControlId) {
    // Make sure we are allowed to send a message
    // and that the contact isn't offline or blocked
    if (oChatWnds[pPlusWnd.Handle].EditChangeAllowed === true)
        // Send the message
        oChatWnds[pPlusWnd.Handle].SendMessage('This message was sent from clicking a control in a window.');
}

// Our window is closed we need to remove
// the association in the object container
function OnTestWindowEvent_Destroyed(pPlusWnd) {
    delete oChatWnds[pPlusWnd.Handle];
}

function OnEvent_ChatWndDestroyed(pChatWnd) {
    for (var i in oChatWnds) {
        if (oChatWnds[i].Handle === pChatWnd.Handle) {
            // Close the original window
            Interop.Call('user32', 'SendMessageW', i, 0x10, 0, 0);
            // Delete the object from the container
            delete oChatWnds[i];
        }
    }
}

This post was edited on 07-30-2010 at 02:53 PM by matty.
07-30-2010 01:33 PM
Profile E-Mail PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
Help with SendMessage() - by Coso on 07-29-2010 at 08:27 PM
RE: Help with SendMessage() - by matty on 07-30-2010 at 01:33 PM
RE: RE: Help with SendMessage() - by Coso on 07-30-2010 at 02:46 PM
RE: Help with SendMessage() - by matty on 07-30-2010 at 02:48 PM
RE: RE: Help with SendMessage() - by Coso on 07-30-2010 at 03:06 PM
RE: Help with SendMessage() - by matty on 07-30-2010 at 04:09 PM


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