What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Rich text format extract using Interop

Rich text format extract using Interop
Author: Message:
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: Rich text format extract using Interop
Javascript code:
// variables
var SF_RTF = 0x2;
var SF_UNICODE = 0x10;
var WM_USER = 0x400;
var EM_STREAMOUT = (WM_USER + 74);
 
// did this just to make sure that function call smaller
var nFlags = SF_RTF | SF_UNICODE;
 
/*
// this was my testing
MsgPlus.CreateWnd('WndMain.xml', 'WndMain');
Debug.DebuggingWindowVisible = true;*/

 
function OnWndMainEvent_CtrlClicked(PlusWnd, ControlId) {
    // check which control is sending the event
    if (ControlId == 'BtnSend') {
        // create a variable to hold the handle of the rtf control
        var CodeBox_hWnd = PlusWnd.GetControlHandle('CodeBox');
        // print this handle to verify for later use
        Debug.Trace('CodeBox Handle: '+CodeBox_hWnd);
        // create our memory block for the EDITSTREAMCALLBACK
        var EDITSTREAMCALLBACK = Interop.Allocate(12);
            /* specify the application defined variable (simply to verify
               the rtf box is the one the function is relating to) */

            EDITSTREAMCALLBACK.WriteDWORD(0, CodeBox_hWnd);
            // get the callback pointer for our function
            EDITSTREAMCALLBACK.WriteDWORD(8, Interop.GetCallbackPtr('EditStreamCallback'));
        // send the message to the control
        // notice the use of Call not Call2; Call is for functions that return an INT, Call2 is to return a BSTR - http://mpscripts.net/docs/ref-interop-call2.php
        Interop.Call('user32', 'SendMessageW', CodeBox_hWnd, EM_STREAMOUT, nFlags, EDITSTREAMCALLBACK.DataPtr);
    }
}
 
function EditStreamCallback(dwCookie, lpBuff, cb, pcb) {
    // dwCookie should match the CodeBox control handle
    Debug.Trace ('dwCookie: '+dwCookie);
    // print the length of the raw rtf data
    Debug.Trace ('cb: '+cb);
    // define a datablock large enough to hold our data
    var lpsz = Interop.Allocate(cb+1);
    // copy the memory from the data buffer to our allocated memory block
    Interop.Call('kernel32', 'RtlMoveMemory', lpsz, lpBuff, lpsz.Size);
    // print out the result
    Debug.Trace(lpsz.ReadString(0, false));
}


This post was edited on 01-26-2010 at 06:39 PM by matty.
01-26-2010 06:36 PM
Profile E-Mail PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
Rich text format extract using Interop - by aztectrev on 01-04-2010 at 07:40 PM
RE: Rich text format extract using Interop - by matty on 01-26-2010 at 03:09 PM
RE: Rich text format extract using Interop - by aztectrev on 01-26-2010 at 04:18 PM
RE: Rich text format extract using Interop - by matty on 01-26-2010 at 04:25 PM
RE: Rich text format extract using Interop - by aztectrev on 01-26-2010 at 04:37 PM
RE: Rich text format extract using Interop - by matty on 01-26-2010 at 05:49 PM
RE: Rich text format extract using Interop - by aztectrev on 01-26-2010 at 06:22 PM
RE: Rich text format extract using Interop - by matty on 01-26-2010 at 06:36 PM
RE: Rich text format extract using Interop - by aztectrev on 01-26-2010 at 06:38 PM
RE: Rich text format extract using Interop - by matty on 01-26-2010 at 07:47 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