Shoutbox

[C++] PlusWnd to MsgPlus - 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: [C++] PlusWnd to MsgPlus (/showthread.php?tid=97617)

[C++] PlusWnd to MsgPlus by enoid on 05-17-2011 at 02:52 PM

I'm using a C++ DLL in which I create a PlusWnd and fill a ListViewControl with it as follows:

code:
extern "C" __declspec(dllexport) void __stdcall TestWindow()
{
    IDispatchPtr Wnd = pMsgPlus->CreateWnd("TestWindow.xml", "Form1");
    _IMPPlusWndPtr pPlusWnd;
    acquireInterfacePtr(Wnd, pPlusWnd);
    ...
    pPlusWnd->LstView_AddItem("LListView", "Testvalue");
    ...
}
Now I want to be able to control the PlusWnd with JScript from MsgPlus itself, but I can't seem to figure out how to return the PlusWnd Object to MsgPlus. I thought about sending the handle/ptr of the object, but I have no idea how to create a PlusWnd Object from it or use the handle/ptr at all.

An other idea would be to create the PlusWnd with MsgPlus and pass the Object/ptr/handle to the DLL, but... same story.
RE: [C++] PlusWnd to MsgPlus by Eljay on 05-17-2011 at 04:03 PM

quote:
Originally posted by enoid
An other idea would be to create the PlusWnd with MsgPlus and pass the Object/ptr/handle to the DLL, but... same story.

This is the simplest way to do it that I could find.

js code:
    var TestWnd = MsgPlus.CreateWnd("TestWnd.xml", "TestWnd");
    Interop.Call(DllPath, "TestWindow", TestWnd);
c++ code:
void __stdcall TestWindow(IDispatchPtr dispPlusWnd)
{
    _IMPPlusWndPtr pPlusWnd;
    acquireInterfacePtr(dispPlusWnd, pPlusWnd);

    pPlusWnd->SetControlText("EditTest", "Hello, World!");
}

The other way should be possible, but I don't think you can return IDispatch pointers directly with Interop.Call. You should be able to create a DataBloc and write the IDispatch* to that then use DataBloc.ReadInterfacePtr to get the object back, but the above way is much easier :P
RE: [C++] PlusWnd to MsgPlus by CookieRevised on 05-17-2011 at 05:10 PM

And if you don't want to juggle with interfaces: you can create the window in the script, and send the window handle from the created window (instead of the object itself) to the DLL. And in the DLL you use the normal Windows APIs to manipulate the controls on the window.

Or, in the same way, if the only thing you do in the DLL is filling that particular listview, send the window handle of that listview control to the DLL. In the DLL you use the normal Windows APIs to populate the listview.


RE: [C++] PlusWnd to MsgPlus by enoid on 05-17-2011 at 05:15 PM

Thanks for that Eljay! I think I'm just going the easy way :) For now I'm just filling the ListView and a few other basic things, so this method would suffice. Thanks again to the both of you!