Importing Multi interface ActiveX control into my windows form

  • Thread starter Thread starter Gilad
  • Start date Start date
G

Gilad

Hi,

I'm trying to use ActiveX control with more than one interface into my
window form.

any way i'm trying to do it (through the IDE or through AxImp.exe) the
only interface exposed is the default interface.
till now the only way i found for doing this is to use the AxImp.exe
and generate a .cs file and then to edit it:

1. declare another interface reference

private MyAx.IMyCompoenent ocx; //generated
private MyAx.IMyCompoenent2 ocx2; //added manually

2. modify AttachInterfaces method
this.ocx = ((MyAx.IMyCompoenent)(this.GetOcx())); //generated
this.ocx2= ((MyAx.IMyCompoenent2)(this.GetOcx())); //added
manually


3. implement each and every method delegation of IMyCompoenent2

i'm sure there is a much easier way for doing it, but i wasn't able to
find it.

thanks in advance
 
Gilad,

That is one way to do it. However, what I would do is just get the
reference returned from the Ocx property, and cast it to the interface that
I want to use later. I don't see the need to add a separate property whose
sole purpose is to perform a task.

Hope this helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top