Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Controls.Add OCX ??????

Status
Not open for further replies.

saramaia

Programmer
Aug 5, 2002
61
PT
Hi

I want to add a User Control to my form.
If i have the userControl in my form i simply do this

Controls.Add "Main.usrControl", "MyControl"
Controls.Item("MyControl").Visible = True

So far so good.
The problem is there are other user controls in other projects I wanted to add to my form too.

When I do

Controls.Add "Other.usrControl", "MyControl1"
Controls.Item("MyControl1").Visible = True

I get the following error:
"Invalid class string
Looking for object with ProgId: Other.usrControl
"

I tried to add the reference to the dll that contains the user control but still it doesn´t work...

Can anyone help me please?
Or give me a work around for this?

Thanks in advance
Sara
 
Sara, I think you cannot add a private user control in other project to your form.

Try changing the other project type to ActiveX control (ocx) and make the the control public (set the Public property to True).

After recompiling the project containing the ActiveX control, add it to your toolbox. Only then, you would be able to add it to your form using Controls.Add method.
 
What about add a form that it´s on a different dll?

Is this possible?

Basically, what i wanted was independency between different modules.

Thanks in advance.
Sara
 
I am getting confused whether you are using DLL or OCX modules.

If you want to import user controls, make sure that you have compiled the host project as ActiveX control, and set its Public property to true.

If you are using ActiveX DLLs, you can late-bind to them and display any forms or do something else, provided that the host dll is capable of doing that.

In both cases make sure that the host dll or ocx have user control/class declared with public scope.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top