mich, have you tried doing that in C first. I havent done it before myself, but Tomasz has shown us how its done in C, I think its posted in the DLL forum /Paul.
_____ From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of tomy_frenchy Sent: Wednesday, 13 December 2006 5:26 PM To: [email protected] Subject: [amibroker] Re: IDispatch and VB ? Thanks Steve to look for my problem. But problem don't come from here. In the program, it is well : "result = MyActiveXDLL.test(C, Extern_Object);" I just change name variable when i writed the mail to be more explicit (and so add a "e" in the mail when i writed the mail). Another other ideas ? IDispatch seems to be a type of variable in C. But for Visual Basic is it ok as variant ? Thanks. Mich. --- In [EMAIL PROTECTED] <mailto:amibroker%40yahoogroups.com> ps.com, "Steve Dugas" <[EMAIL PROTECTED]> wrote: > > Hi - Did you mispell Extern_Object in this line? > > result = MyActiveXDLL.test(C, Externe_Object); // send price array > > Steve > > ----- Original Message ----- > From: "tomy_frenchy" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED] <mailto:amibroker%40yahoogroups.com> ps.com> > Sent: Tuesday, December 12, 2006 11:08 PM > Subject: [amibroker] Re: IDispatch and VB ? > > > > It makes two days i try to make it work and nothing to do. > > Sorry to come back with this problem. > > If someone can help me please, i will be more than happy. > > I don't know if problem come from AB, the connection between AB and > > DLL or the DLL. > > > > In fact, when i create an object in Amibroker with Create.Object > > function, it returns an IDispatch object (_trace confirm it). > > > > From an IDispatch object, i have read that we can retrieve object > > method by using something like that : > > idmethod = IDispatch.GetIDsOfNames("name_method") > > method = IDispatch.Invoke(idmethod) > > > > I call an COM/ActiveX DLL from amibroker where i pass the IDispatch > > as parameters function. > > Problem is that the COM/ActiveX DLL side see nothing... like if > > sending IDispatch was null. But _trace from Amibroker see the > > variable like an IDispatch object. > > > > So the problem can be : > > 1- Amibroker don't send the IDispatch object to the ActiveX DLL > > 2- At some point between Amibroker and the ActiveX DLL the IDispatch > > object is lost > > 3- The ActiveX DLL don't catch the IDisaptch object > > > > For 1, if IDispatch is send to _TRACE function, why it wouldn't be > > send to the ActiveX DLL...? so i don't think it come from here > > For 2, the array type are well transmitted to the ActiveX DLL, so the > > Dispatch object should be too well transmitted > > For 3, ActiveX DLL catch well array data coming from AFL so why not > > the IDispatch object... > > > > So i am really lost here... > > Only thing i was thinking is debbuger don't see IDispatch > > object...but when i send back the variable to Amibroker, and make a > > _trace of the result send back from the DLL, there is no more > > <IDispatch> but {empty} : ( > > > > > > Some very simple code to explain, with comments to important point > > and test i made : > > > > AFL side : > > //---------------------- > > Extern_Object = CreateObject("Library.Class"); //i cannot modify this > > object > > MyActiveXDLL = CreateObject("MyDLL.MyClass"); // my Active X DLL > > > > _TRACE("IDispatch object:"+Extern_Object); //return "<IDispatch>" > > _TRACE("My ActiveX DLL:"+ActiveXDLL); //return "<IDispatch>" > > > > result = MyActiveXDLL.test(C, Externe_Object); // send price array > > and IDispatch object to the activex dll > > _TRACE("Result send back:"+result); > > //---------------------- > > > > VBS side : > > '----------------------- > > Public Function test(ByRef price As Variant, ByRef externobject As > > Variant) As Variant > > > > 'here debugging told me : > > 'price contains the C array comming from AmiBroker, all is ok > > 'externobject contain nothing !? arhhhh > > 'i would like to call some methods of the externobject here > > > > test = price > > End Function > > '----------------------- > > > > > > In amibroker i got the price array as value for "result", not problem. > > But if i put 'test = externobject' instead 'test = price' in the VBS > > side, "result" under Amibroker is empty, there is no more <IDispatch> > > (_trace say {empty})... he disapear at some point : )) !? > > > > I tried "ByRef externobject" and "ByVal externobject" for function > > declaration. Change nothing to the problem. > > > > > > Thanks, > > Mich. > > > > > > --- In [EMAIL PROTECTED] <mailto:amibroker%40yahoogroups.com> ps.com, "tomy_frenchy" <michel_b_g@> > > wrote: > >> > >> Hello, > >> > >> I would like to create a static object in AFL and after send this > >> pointer (called IDispatch type variable) to a Visual Basic > >> COM/ActiveX DLL. > >> After i would like to call this object created in AFL amibroker > > from > >> the VB code. > >> > >> I need to use VB code because the COM object created fom AFL return > >> matrix, so i need to change the result to array before sending it > >> back to Amibroker. > >> And another purpose of this is that create.object is long because > > it > >> is a heavy object, so during recursion with multiple call to the VB > >> code in AFL it is really slow. I would like to create the object > > just > >> one time with amibroker, and after call directly the method from > >> Visual Basic without create a new object. > >> > >> The code i use are : > >> > >> AFL code : > >> ------------------------------------------ > >> aClass = CreateObject("carre.carreclass"); //object to be called in > >> the VB code, we can use CreateStaticObject too here > >> myobj = CreateObject("Project1.Class1"); // VB COM/ActiveX DLL > >> _TRACE("aClass:"+aClass); // return IDispatch type variable > >> _TRACE("myobj:"+myobj); // return IDispatch type variable > >> > >> result = myobj.test(200, aClass); > >> ------------------------------------------ > >> > >> VB code : > >> ------------------------------------------ > >> Public Function testVB(n As Variant, aClass As Variant) As Variant > >> 'IF I DEBUG HERE "aClass" is empty !! > >> Dim matrix As Variant > >> Dim result() As Variant > >> > >> Call aClass.fct1(matrix, n) > >> > >> ... processing matrix variable and VB code here ... > >> > >> ' IF I SEND BACK testVB = aClass to amibroker, a _trace under > >> amibroker no more say that variable is IDispatch, but say it is > >> empty !! > >> > >> testVB = result > >> > >> End Function > >> ------------------------------------------ > >> > >> > >> Any help is welcome ! Thanks. > >> > >> Cheers, > >> Mich > >> > > > > > > > > > > Please note that this group is for discussion between users only. > > > > To get support from AmiBroker please send an e-mail directly to > > SUPPORT {at} amibroker.com > > > > For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG: > > http://www.amibroke <http://www.amibroker.com/devlog/> r.com/devlog/ > > > > For other support material please check also: > > http://www.amibroke <http://www.amibroker.com/support.html> r.com/support.html > > > > Yahoo! Groups Links > > > > > > > > >
