What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » [C++] PlusWnd to MsgPlus

[C++] PlusWnd to MsgPlus
Author: Message:
enoid
New Member
*


Posts: 6
Joined: May 2011
O.P. [C++] PlusWnd to MsgPlus
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.
05-17-2011 02:52 PM
Profile PM Find Quote Report
Eljay
Elite Member
*****

Avatar
:O

Posts: 2949
Reputation: 77
– / Male / –
Joined: May 2004
RE: [C++] PlusWnd to MsgPlus
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.

Javascript 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
05-17-2011 04:03 PM
Profile PM Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15517
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: [C++] PlusWnd to MsgPlus
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.

This post was edited on 05-17-2011 at 05:14 PM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
05-17-2011 05:10 PM
Profile PM Find Quote Report
enoid
New Member
*


Posts: 6
Joined: May 2011
O.P. RE: [C++] PlusWnd to MsgPlus
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!
05-17-2011 05:15 PM
Profile PM Find Quote Report
« Next Oldest Return to Top Next Newest »


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