Board index » delphi » VB ActiveX Control not playing well

VB ActiveX Control not playing well

I've got an ActiveX control created in VB.  The control works fine in VB :-o
, but when I try to use it in Delphi (5.0) I can't call any of the exposed
methods.  I can get the properties of the control but not the methods.
It's been a long time since I've used Delphi (I'm usually in VC), but I know
that around Delphi 3.0 there were some vtable problems with using VB ActiveX
controls.  To work around you had to call CreateOleObject() and get a
reference to IDispatch.  Something to do with VB not setting the vtables up
correctly (sparse vtable, I think).  It seems that you would assign the
IDispatch reference to a variant variable and could get around it.  I've
just installed Delphi 5 and am running into some problems.

I know this is a vague question but can anyone give me a hint as to where to
look, or something to try?  Is this a marshalling problem?

The control has an edit box, button, label, etc.. If I call any of the
methods associated with these contained controls it works fine.  I can get
at the properties of the 'user-control' (the container), but if I try to
call a method of the user-control, I get a crash with no obvious way to
debug or get a readable error back.  Initially, I was getting an
EIntfCastError back, and to be honest I don't know what I did but I haven't
seen that error for awhile.  Now I can't even trap the error, it just
crashes.

Any tips or help would be greatly appreciated.

Thanks in advance,

Boone Brumagen

 

Re:VB ActiveX Control not playing well


I meant to add that I'm using variant not OleVariant and wondered if that
might play in?

Also, I'm not sure what code would be helpful but let me know and I'll send
it off!

Roughly:  (forgive my rusty Delphi)
______________________________________
...
var
    v: variant;
    i: integer;
begin

    v := CreateOleObject('vbObj.IvbObj');
    i := v.property;  // works
    v.anyMethod();  // crash
// or
    i := v.anyFunction(); // crash

end;
______________________________________

Thanks,

Boone Brumagen

Quote
"Boone Brumagen" <n...@barakdev.com> wrote in message

news:398b8a38$1_2@dnews...
Quote
> I've got an ActiveX control created in VB.  The control works fine in VB
:-o
> , but when I try to use it in Delphi (5.0) I can't call any of the exposed
> methods.  I can get the properties of the control but not the methods.
> It's been a long time since I've used Delphi (I'm usually in VC), but I
know
> that around Delphi 3.0 there were some vtable problems with using VB
ActiveX
> controls.  To work around you had to call CreateOleObject() and get a
> reference to IDispatch.  Something to do with VB not setting the vtables
up
> correctly (sparse vtable, I think).  It seems that you would assign the
> IDispatch reference to a variant variable and could get around it.  I've
> just installed Delphi 5 and am running into some problems.

> I know this is a vague question but can anyone give me a hint as to where
to
> look, or something to try?  Is this a marshalling problem?

> The control has an edit box, button, label, etc.. If I call any of the
> methods associated with these contained controls it works fine.  I can get
> at the properties of the 'user-control' (the container), but if I try to
> call a method of the user-control, I get a crash with no obvious way to
> debug or get a readable error back.  Initially, I was getting an
> EIntfCastError back, and to be honest I don't know what I did but I
haven't
> seen that error for awhile.  Now I can't even trap the error, it just
> crashes.

> Any tips or help would be greatly appreciated.

> Thanks in advance,

> Boone Brumagen

Re:VB ActiveX Control not playing well


This sounds like the sparse vtable problem. Try installing D5 SP1 and
reimport your type library and see what happens.

have fun
--
Binh Ly
http://www.techvanguards.com

Quote
"Boone Brumagen" <n...@barakdev.com> wrote in message

news:398b8a38$1_2@dnews...
Quote
> I've got an ActiveX control created in VB.  The control works fine in VB
:-o
> , but when I try to use it in Delphi (5.0) I can't call any of the exposed
> methods.  I can get the properties of the control but not the methods.
> It's been a long time since I've used Delphi (I'm usually in VC), but I
know
> that around Delphi 3.0 there were some vtable problems with using VB
ActiveX
> controls.  To work around you had to call CreateOleObject() and get a
> reference to IDispatch.  Something to do with VB not setting the vtables
up
> correctly (sparse vtable, I think).  It seems that you would assign the
> IDispatch reference to a variant variable and could get around it.  I've
> just installed Delphi 5 and am running into some problems.

> I know this is a vague question but can anyone give me a hint as to where
to
> look, or something to try?  Is this a marshalling problem?

> The control has an edit box, button, label, etc.. If I call any of the
> methods associated with these contained controls it works fine.  I can get
> at the properties of the 'user-control' (the container), but if I try to
> call a method of the user-control, I get a crash with no obvious way to
> debug or get a readable error back.  Initially, I was getting an
> EIntfCastError back, and to be honest I don't know what I did but I
haven't
> seen that error for awhile.  Now I can't even trap the error, it just
> crashes.

> Any tips or help would be greatly appreciated.

> Thanks in advance,

> Boone Brumagen

Other Threads