NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How to activate activeX control

Hi,

 

I have problem about how to activate an activeX control in teststand. I created a c# form dll which has an activeX control. In teststand, i created an object for that form and want to use the functions in that dll. But i find that if i do not run that form, the activeX control can not be activated  by only createing an object for that form. in fact, i do not want to run that form.

 

I wonder someone may help me to solve this problem. Thanks in advance!

 

SIda

0 Kudos
Message 1 of 4
(4,262 Views)

I'm assuming you are already running in an STA thread. If so, just create a hidden form that hosts the activex control. You don't have to ever make the form visible, just create it. Most ActiveX controls expect to be hosted on an ActiveX container, so there is likely no other way than this. The ActiveX container itself though can be hidden, so no one will ever see or be able to interact with the control (which sounds like what you want).

 

You might need to call CreateHandle() or CreateControl() on the form, though I'm not sure about this.

 

Hope this helps,

-Doug

Message 2 of 4
(4,235 Views)

Thanks for your help.

 

I tried create control(), but it does not work as you have to activate on the form. i use application.run() to run the hide form but it always runs and i do not know how to stop it...

0 Kudos
Message 3 of 4
(4,206 Views)
System.Windows.Forms.Form hiddenForm = new System.Windows.Forms.Form();
MyNamespace.Ax.AxMyClass myobject = new MyNamespace.Ax.AxMyClass();
((System.ComponentModel.ISupportInitialize)(myobject)).BeginInit();
hiddenForm.Controls.Add(myobject);
((System.ComponentModel.ISupportInitialize)(myobject)).EndInit();

 I think the above should work.

 

-Doug

0 Kudos
Message 4 of 4
(4,179 Views)