Using an ActiveX control without GUI ?

  • Hi everyone,

    I started developping an application for controlling motorized stages a while ago under Qt with Visual Studio, and I now face a strange problem.

    One of the stages constructor only provides an ActiveX tool for controlling its devices. I can put this tool into a QAxWidget on my GUI, and then send it commands programmatically or use the input widgets inside the ActiveX box. But I'd like only to have access programmatically to this control. The workaround I used until now is to put the QWidget on an hidden page of a QStackedWidget, but I would like to put it in a different class than my GUI, and even a different thread because the interface freezes while the stages are working.

    Is there a way to instantiate a ActiveX control without putting it into a GUI ?



  • Hi Koann,

    an ActiveX control is a UI COM object. UI means, it has some UI to display. Theoretically, you can instantiate it like each other server COM object, but then not as ActiveX control, try CoCreateInstance(), it will work and you will get valid pointers. But whether the object will work as expected, I can't tell, es the windows of the active X will not be created.

    If you use QAxWidget to create the object, you are bound to the main thread! And also, creating the object from another thread with CoCreateInstance will only have partly success, as it depends on the appartement model of the created object, where it will be created and how it can be used.

  • Thank you Gerolf for your explanation,

    All of the methods that I'd like to use on the ActiveX control have an option for being non-blocking, so even using an QAxWidget there is no more UI freezing problem. I still wanted to try the CoCreateInstance() method, and I'm having trouble with the includes of my project. I scanned the ActiveX object with OLE/COM Object Viewer to find the related interfaces, and I am know trying to access their methods using "this guide": The problem is I don't know how to make the compiler recognize the interfaces in my project. Is there a special file to include ? The only one that is related to the ActiveX control on my computer is an .ocx file.

    For the QAxWidget solution, I experience another problem. I can access the methods of the control itself with dynamicCall() methods, but right now I'm trying to listen to events that are being fired by the controller whenever the stage stops for example. The code I'm using is based on this "doc page": It is the following :
    xMotor = new QAxWidget(this);
    // Set the serial number of the stage
    xMotor->dynamicCall("setHWSerialNum(long)", 90825074);
    //Connect the event to a Qt slot in this class
    connect(xMotor, SIGNAL(MoveStopped(long)), this, SLOT(updatePositionData()));
    xMotor->dynamicCall("startCtrl()"); // Starts the stage
    // Test method, that moves the stage to a position of 50
    xMotor->dynamicCall("moveAbsoluteEx(long, float, float, bool)", 0, (float) 50, 0 , 0); @

    With this code, the stages moves correctly, but the compilers says :
    @No such signal QAxWidget::MoveStopped(long)@
    Is there a way to listen to the events of the controller ?


  • Hi Koann,

    the COM guide you used is used for server objects. To create activeX objects (which typically have a UI).
    If you want to use the interfaces inside your app, you can use #import on the dll/tlb containing the interfaces (if you use the Microsoft toolchain).

  • Hey VideoCapX is a activex control software, i am using it 3 years already and it works fine for me.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.