LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

ActiveX Wizard Initialisation Query

I am using an ActiveX control, supplied with a Thorlabs Stepper Motor Positioning system. CVI seemed to find and create an instrument for it, with a bunch of functions, including one as follows:

 

HRESULT BSC102_New_DMG17Motor (const char *Server,

                               int Support_Multithreading,

                               LCID Locale, int Reserved,

                               CAObjHandle *Object_Handle);

 

I took this function at face value and tried to use it to initiate communication with the instrument. It failed. Looking at the Help on ActiveX programming, I found the following information:

 

"For each interface that the ActiveX server supports, the driver contains a creation function that you can use to programmatically create an instance of the ActiveX control. The name of the function is of the form <InstrumentPrefix>_New<InterfaceName>. You pass to this function the panel, label and coordinates of the new control. The function returns a control ID, which you use to identify the control when you pass it to functions from the User Interface Library."

 

This seems to be a very different interface to the one generated by the wizard - the parameters are totally different, although the function name itself seems accurate. Can anyone shed any light in this area?

 

JR

0 Kudos
Message 1 of 4
(3,442 Views)

JR,

 

The help that you're quoting is from the "Programming with ActiveX Controls" topic. ActiveX controls are a special case of an ActiveX server: they have a GUI which you can embed inside a CVI panel.

 

The function prototype that you have here doesn't seem to be for an ActiveX control. It seeems to be for a generic ActiveX server, hence it does not have the UI parameters.

 

You can find examples of both types, in samples\userint\activex and samples\activex, respectively.

 

Luis

0 Kudos
Message 2 of 4
(3,437 Views)

Thanks Luis. Despite using CVI for very many years, I have mananged to avoid ActiveX up to now - this is my first one Smiley Surprised

 

I created an ActiveX Controller from the Wizard, and it gave me an instrument with, amongst many others, the function prototype I listed. Is this not correct? Or is an ActiveX Control different to an ActiveX Controller!! Why would the ActiveX Controller Wizard (CVI 7.1) give me a prototype for an ActiveX Server function? I'll have to wait until next week to get back to my CVI system and check out the samples.

 

JR

0 Kudos
Message 3 of 4
(3,430 Views)

That's right. In ActiveX parlance, a "controller" has nothing to do with a "control".

 

In ActiveX, there really are only servers and clients, and "controller" is just another name for a client. The reason for the name probably goes back to when the most common use for ActiveX was automation, and a controller was a particular type of client which "controlled" an automation server.

 

The CVI ActiveX Controller wizard helps you create the programmatic interface that a client program will use to talk to a server. Note that there is also a server wizard, which will help you create an ActiveX server (but not a control! you cannot use CVI to create ActiveX controls).

 

So what are ActiveX controls? Controls are a special kind of ActiveX server which can also operated by the end user like any other GUI control (knobs, slides, etc...) They can be hosted by something called an ActiveX container. A CVI panel can act like an ActiveX container, and thus you can embed an ActiveX control onto a CVI panel. Typically, you do this in the UI editor by selecting "ActiveX" as the type of control you want to create, and then selecting from amongst the various controls you have registed on your PC. You can then use the ActiveX Controller wizard to create a programmatic interface which will allow you programmatic access to the control.

 

Even though the ActiveX Controller wizard can be used to generate a programmatic interface for a server, or for a control, it will create slightly different interfaces for each type. And the primary difference is precisely for the creation functions. This function, BSC102_New_DMG17Motor, is a creation function for an object in an ActiveX server -- not for an object in an ActiveX control.

 

Luis

0 Kudos
Message 4 of 4
(3,397 Views)