Board index » cppbuilder » MS ScripControl - AddObject() problem
Uli
![]() CBuilder Developer |
MS ScripControl - AddObject() problem2007-05-30 03:22:25 PM cppbuilder61 Hello all, I have problems using the MS-ScripControl regarding the AddObject() method. This means I can't refer to an internal function (of my application) which I supposed to offer to the script component via AddObject(). (Let me say that the scripting functionality itself works properly - I can use AddCode() / Eval() ... so that I'm basically able to run simple scripts.) For testing purposes I created a COM-automation object "ScriptControlTest" which has the interface "ITest" with the method MyMessage(BSTR szMsg) which only shows a message box. Here's a code snippet in which I tried out several alternatives: //------------------- typedef Scriptcontroltest_tlb::ITestPtr IScriptTestPtr; IScriptTestPtr pIScriptTest; hr = pIScriptTest.CreateInstance(L"ScriptControlTest.Test", NULL, CLSCTX_INPROC_SERVER ); ScriptControl1->AddObject(L"Test", pIScriptTest, false); //------------------- Variant vAutoObj.CreateObject(L"ScriptControlTest.Test"); ScriptControl1->AddObject(L"Test", vAutoObj, false); //------------------- Variant vAutoObj = CreateOleObject("ScriptControlTest.Test"); ScriptControl1->AddObject(L"Test", vAutoObj, false); //------------------- But all my efforts only lead to the effect that I received the message "'Test' is undefined" when I tried to run the following script code for example (JScrip syntax): Test.MyMessage("Hello"); Has anyone experience with that and can give me a hint or is there a BCB (NOT Delphi!!!) sample project/tutorial anywhere? Thanks, Uli. |