How do you create an ActiveX control at run-time (no form)?

J

Jink Welby

Can anyone tell me how to create at ActiveX control ar run-time in code
without using a form? I want to instantiate and use the control from within
a non-visual class.

Please help!

Thanks in advance,

Jink
 
D

Dmitriy Lapshin [C# / .NET MVP]

Here's what you can try:

1) Reference the DLL containinf the ActiveX as a COM dll. An interop
assembly will be created and added to the project references.
2) Examine the generated assembly with Object Browser to find out which
class corresponds to the control (usually it is named AcmeControlClass if
the control itself is named AcmeControl).
3) Create an instance of that class with the "new" operator.

However, it actually depends on the control itself whether you will be able
to use it in the intended way or not. If all the control code assumes it is
visible, has a window and bounds etc., your attempt will most likely fail.
 

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

Top