Results 1 to 12 of 12

Thread: Using ActiveX controls and dumpcpp

  1. #1
    Join Date
    Jun 2011
    Posts
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Using ActiveX controls and dumpcpp

    hello:
    I get a activex controls (.OCX file) from manufacturer, this active controls can access a PCI card. I want to build a GUI to control this card. I use dumpcpp to create a "dospotpc.h" and "dospotpc.cpp" file:

    dumpcpp {74676A0F-BB65-48A0-8044-F453692E9A8A} -o dospotpc

    in file "dospotpc.h"
    Qt Code:
    1. /****************************************************************************
    2. **
    3. ** Namespace DOSPOTPCLib generated by dumpcpp from type library
    4. ** C:\Program Files\DoSpotPC.OCX\DoSpotPC.ocx
    5. **
    6. ****************************************************************************/
    7.  
    8. #ifndef QAX_DUMPCPP_DOSPOTPCLIB_H
    9. #define QAX_DUMPCPP_DOSPOTPCLIB_H
    10.  
    11. // Define this symbol to __declspec(dllexport) or __declspec(dllimport)
    12. #ifndef DOSPOTPCLIB_EXPORT
    13. #define DOSPOTPCLIB_EXPORT
    14. #endif
    15.  
    16. #include <qaxobject.h>
    17. #include <qaxwidget.h>
    18. #include <qdatetime.h>
    19. #include <qpixmap.h>
    20.  
    21. struct IDispatch;
    22.  
    23.  
    24. // Referenced namespace
    25.  
    26. namespace DOSPOTPCLib {
    27.  
    28.  
    29. class DOSPOTPCLIB_EXPORT _DDoSpotPC : public QAxObject
    30. {
    31. public:
    32. _DDoSpotPC(IDispatch *subobject = 0, QAxObject *parent = 0)
    33. : QAxObject((IUnknown*)subobject, parent)
    34. {
    35. internalRelease();
    36. }
    37.  
    38. /*
    39.   Method AboutBox
    40.  
    41.   For more information, see help context 0 in C:\Program Files\DoSpotPC.OCX\DoSpotPC.hlp.
    42.   */
    43. inline void AboutBox();
    44.  
    45. /*
    46.   Method doGetDetectorsName
    47.  
    48.   For more information, see help context 0 in C:\Program Files\DoSpotPC.OCX\DoSpotPC.hlp.
    49.   */
    50. inline int doGetDetectorsName(int numDev, QString& DetSN1, QString& DetSN2);
    51.  
    52. /*
    53.   Method doGetDeviceNumber
    54.  
    55.   For more information, see help context 0 in C:\Program Files\DoSpotPC.OCX\DoSpotPC.hlp.
    56.   */
    57. inline int doGetDeviceNumber(int Hardware, int& numDev);
    58.  
    59. /*
    60.   Method doGetMeasureData
    61.  
    62.   For more information, see help context 0 in C:\Program Files\DoSpotPC.OCX\DoSpotPC.hlp.
    63.   */
    64. inline int doGetMeasureData(int numDev, QVariant& Xo, QVariant& Yo, QVariant& Po);
    65.  
    66. /*
    67.   Method doGetMeasureDataEx
    68.  
    69.   For more information, see help context 0 in C:\Program Files\DoSpotPC.OCX\DoSpotPC.hlp.
    70.   */
    71. inline int doGetMeasureDataEx(int numDev, double& Xo, double& Yo, double& Po);
    72.  
    73. /*
    74.   Method doGetQuadPower
    75.  
    76.   For more information, see help context 0 in C:\Program Files\DoSpotPC.OCX\DoSpotPC.hlp.
    77.   */
    78. inline int doGetQuadPower(int numDev, QVariant& PQ1, QVariant& PQ2);
    79.  
    80. /*
    81.   Method doSetHardware
    82.  
    83.   For more information, see help context 0 in C:\Program Files\DoSpotPC.OCX\DoSpotPC.hlp.
    84.   */
    85. inline int doSetHardware(int Hardware, int numDev);
    86.  
    87. /*
    88.   Method doSetSystemType
    89.  
    90.   For more information, see help context 0 in C:\Program Files\DoSpotPC.OCX\DoSpotPC.hlp.
    91.   */
    92. inline void doSetSystemType(int AppName);
    93.  
    94. /*
    95.   Method doSetWavelength
    96.  
    97.   For more information, see help context 0 in C:\Program Files\DoSpotPC.OCX\DoSpotPC.hlp.
    98.   */
    99. inline int doSetWavelength(int numDev, int Channel, int Wave);
    100.  
    101. // meta object functions
    102. static const QMetaObject staticMetaObject;
    103. virtual const QMetaObject *metaObject() const { return &staticMetaObject; }
    104. virtual void *qt_metacast(const char *);
    105. };
    106.  
    107. // skipping event interface _DDoSpotPCEvents
    108.  
    109. // Actual coclasses
    110. class DOSPOTPCLIB_EXPORT DoSpotPC : public QAxWidget
    111. {
    112. public:
    113. DoSpotPC(QWidget *parent = 0, Qt::WindowFlags f = 0)
    114. : QAxWidget(parent, f)
    115. {
    116. setControl("{74676a0f-bb65-48a0-8044-f453692e9a8a}");
    117. }
    118.  
    119. /*
    120.   Method AboutBox
    121.  
    122.   For more information, see help context 0 in C:\Program Files\DoSpotPC.OCX\DoSpotPC.hlp.
    123.   */
    124. inline void AboutBox();
    125.  
    126. /*
    127.   Method doGetDetectorsName
    128.  
    129.   For more information, see help context 0 in C:\Program Files\DoSpotPC.OCX\DoSpotPC.hlp.
    130.   */
    131. inline int doGetDetectorsName(int numDev, QString& DetSN1, QString& DetSN2);
    132.  
    133. /*
    134.   Method doGetDeviceNumber
    135.  
    136.   For more information, see help context 0 in C:\Program Files\DoSpotPC.OCX\DoSpotPC.hlp.
    137.   */
    138. inline int doGetDeviceNumber(int Hardware, int& numDev);
    139.  
    140. /*
    141.   Method doGetMeasureData
    142.  
    143.   For more information, see help context 0 in C:\Program Files\DoSpotPC.OCX\DoSpotPC.hlp.
    144.   */
    145. inline int doGetMeasureData(int numDev, QVariant& Xo, QVariant& Yo, QVariant& Po);
    146.  
    147. /*
    148.   Method doGetMeasureDataEx
    149.  
    150.   For more information, see help context 0 in C:\Program Files\DoSpotPC.OCX\DoSpotPC.hlp.
    151.   */
    152. inline int doGetMeasureDataEx(int numDev, double& Xo, double& Yo, double& Po);
    153.  
    154. /*
    155.   Method doGetQuadPower
    156.  
    157.   For more information, see help context 0 in C:\Program Files\DoSpotPC.OCX\DoSpotPC.hlp.
    158.   */
    159. inline int doGetQuadPower(int numDev, QVariant& PQ1, QVariant& PQ2);
    160.  
    161. /*
    162.   Method doSetHardware
    163.  
    164.   For more information, see help context 0 in C:\Program Files\DoSpotPC.OCX\DoSpotPC.hlp.
    165.   */
    166. inline int doSetHardware(int Hardware, int numDev);
    167.  
    168. /*
    169.   Method doSetSystemType
    170.  
    171.   For more information, see help context 0 in C:\Program Files\DoSpotPC.OCX\DoSpotPC.hlp.
    172.   */
    173. inline void doSetSystemType(int AppName);
    174.  
    175. /*
    176.   Method doSetWavelength
    177.  
    178.   For more information, see help context 0 in C:\Program Files\DoSpotPC.OCX\DoSpotPC.hlp.
    179.   */
    180. inline int doSetWavelength(int numDev, int Channel, int Wave);
    181.  
    182. // meta object functions
    183. static const QMetaObject staticMetaObject;
    184. virtual const QMetaObject *metaObject() const { return &staticMetaObject; }
    185. virtual void *qt_metacast(const char *);
    186. };
    187. ...................................
    To copy to clipboard, switch view to plain text mode 

    in class "DoSpotPC", this member function prototype:
    Qt Code:
    1. inline int doGetDeviceNumber(int Hardware, int& numDev);
    To copy to clipboard, switch view to plain text mode 
    is not correct, according to the manual, this member function prototype should be
    Qt Code:
    1. short doGetDeviceNumber(short Hardware, short* numDev);
    To copy to clipboard, switch view to plain text mode 

    I get stuck at here, the parameter 1 type should be a pointer. if I use this function like this:
    Qt Code:
    1. int devNum;
    2. s->doGetDeviceNumber(1, devNum);
    To copy to clipboard, switch view to plain text mode 
    I will get following error:
    "Error calling IDispatch member: Type mismatch in parameter 1"

    please give me some help, thx.

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Using ActiveX controls and dumpcpp

    How is this related to Qt?
    If I understand correctly, your problems have to do with OCX interface, not with the QAxObject...
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Jun 2011
    Posts
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Using ActiveX controls and dumpcpp

    hello:
    I try to use "dynamicCall" function, too, like following code:

    Qt Code:
    1. QAxWidget *doSpot;
    2. doSpot = new QAxWidget(this);
    3. doSpot->setControl("{74676A0F-BB65-48A0-8044-F453692E9A8A}");
    4.  
    5. QString str1 = "doSetSystemType(int)";
    6. QList<QVariant> vars1;
    7. QVariant res1;
    8. vars1 << 0;
    9. res1 = doSpot->dynamicCall(str1.toLatin1(), vars1);
    10. qDebug() << res1 << vars1[0];
    11.  
    12. QString str2 = "doGetDeviceNumber(int, int&)";
    13. QList<QVariant> vars2;
    14. QVariant res2;
    15. vars2 << 1 << "";
    16. res2 = doSpot->dynamicCall(str2.toLatin1(), vars2);
    17. qDebug() << res2 << vars2[0] << vars2[1];
    18.  
    19. QString str3 = "doSetHardware(int, int)";
    20. QList<QVariant> vars3;
    21. QVariant res3;
    22. vars3 << 1 << 2;
    23. res3 = doSpot->dynamicCall(str3.toLatin1(), vars3);
    24. qDebug() << res3 << vars3[0] << vars3[1];
    25.  
    26. QString str4 = "doSetWavelength(int, int, int)";
    27. QList<QVariant> vars4;
    28. QVariant res4;
    29. vars4 << 1 << 1 << 633;
    30. res4 = doSpot->dynamicCall(str4.toLatin1(), vars4);
    31. qDebug() << res4 << vars4[0] << vars4[1] << vars4[2];
    32. vars4.clear();
    33. vars4 << 1 << 2 << 633;
    34. res4 = doSpot->dynamicCall(str4.toLatin1(), vars4);
    35. qDebug() << res4 << vars4[0] << vars4[1] << vars4[2];
    36. vars4.clear();
    37. vars4 << 2 << 1 << 633;
    38. res4 = doSpot->dynamicCall(str4.toLatin1(), vars4);
    39. qDebug() << res4 << vars4[0] << vars4[1] << vars4[2];
    40. vars4.clear();
    41. vars4 << 2 << 2 << 633;
    42. res4 = doSpot->dynamicCall(str4.toLatin1(), vars4);
    43. qDebug() << res4 << vars4[0] << vars4[1] << vars4[2];
    To copy to clipboard, switch view to plain text mode 

    it is fine. then, I want to get some values through function "doGetMeasureDataEx", I have a problem. following code and mention is this function prototype describe in manual:

    Qt Code:
    1. short doGetMeasureDataEx(float* measuredData);
    To copy to clipboard, switch view to plain text mode 

    my problem is on argument "measuredData", the argument is a array of two element returned, ie, I can get 2 measured data at array "measuredData". . then I use dynamicCall as following code:

    Qt Code:
    1. QString str5 = "doGetMeasureDataEx(double&)";
    2. QVariant vars5 = 0.0;
    3. QVariant res5;
    4. res5 = doSpot->dynamicCall(str5.toLatin1(), vars5);
    To copy to clipboard, switch view to plain text mode 

    I only can get 1 data, how to get this two data, please give me some help, thx.

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Using ActiveX controls and dumpcpp

    My guess is that you have to use this variant for dynamicCall():
    http://doc.qt.nokia.com/latest/qaxba...#dynamicCall-2
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  5. #5
    Join Date
    Jun 2011
    Posts
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Using ActiveX controls and dumpcpp

    to high_flyer:
    thank for your answer.

    I just simplify this function prototype to explain my question, this actual prototype is

    Qt Code:
    1. short doGetMeasureDataEx(short iDev, float* x, float* y, float* p);
    To copy to clipboard, switch view to plain text mode 

    the argument iDev is in-parameter. these arguments (x, y, p) are out-parameter and two element array, so, I should get 6 measured data totally.

    and in my qt' test program, the getting data code is :

    Qt Code:
    1. QString str5 = "doGetMeasureDataEx(int, double&, double&, double&)";
    2. QList<QVariant> vars5;
    3. QVariant res5;
    4. vars5 << 1 << 0.0 << 0.0 << 0.0 ;
    5. res5 = doSpot->dynamicCall(str5.toLatin1(), vars5);
    To copy to clipboard, switch view to plain text mode 

    so, vars[1], vars[2] and vars[3] is first element data of x ,y and p, respectively. I can't get second data. please help me to solve this problem, thx.

  6. #6
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Using ActiveX controls and dumpcpp

    Did you read my last answer?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  7. The following user says thank you to high_flyer for this useful post:


  8. #7
    Join Date
    Jun 2011
    Posts
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Using ActiveX controls and dumpcpp

    to high_flyer:
    did you mean that I have to use this function "QVariant QAxBase::dynamicCall ( const char * function, QList<QVariant> & vars )"?, in my last post, I have used this function for dynamicCall() as follwing:

    Qt Code:
    1. QString str5 = "doGetMeasureDataEx(int, double&, double&, double&)";
    2. QList<QVariant> vars5;
    3. QVariant res5;
    4. vars5 << 1 << 0.0 << 0.0 << 0.0 ;
    5. res5 = doSpot->dynamicCall(str5.toLatin1(), vars5);
    To copy to clipboard, switch view to plain text mode 

    I don't understand your meaning completely, please give me more explanation. thank for your answer.

  9. #8
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Using ActiveX controls and dumpcpp

    Sorry, for some reason my brain saw 'res5' instead of 'vars5'.

    So do you mean 'vars5' has only one element in the list after the call?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  10. #9
    Join Date
    Jun 2011
    Posts
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Using ActiveX controls and dumpcpp

    to high_flyer:
    following code is the function prototype described in manual:

    "short doGetMeasureDataEx(short iDev, float* x, float* y, float* p);"

    the argument 0 ("iDev") is in-parameter. Arguments 1, 2 and 3("x", "y", "p") are out-parameter, two element array and pointer, so, I should get 6 values totally. these 6 values are stored in x[0], x[1], y[0], y[1], p[0], p[1].

    and in my qt' test program, after calling "dynamicCall()" in my machine, the vars5 is: vars5[0] = 1, vars5[1] = -12.143, vars5[2] = -0.973, vars5[3] = 0.812. ie, vars5[0] = iDev, vars5[1] = x[0], vars5[2] = y[0], vars5[3] = p[0]. I can't get x[1], y[1], p[1] values.

    the Qvariant can be used as a pointer? thank for your answer.

  11. #10
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Using ActiveX controls and dumpcpp

    Ah... now I see that you didn't use the correct function signature - you have pointers as params but you were using references...
    You used:
    Qt Code:
    1. QString str5 = "doGetMeasureDataEx(int, double&, double&, double&)";
    To copy to clipboard, switch view to plain text mode 
    Where as the function signature is:
    Qt Code:
    1. short doGetMeasureDataEx(short iDev, float* x, float* y, float* p);
    To copy to clipboard, switch view to plain text mode 
    So no wonder it doesn't work.

    What you can try, is cast the double pointer addresses to long, set that as your QVariable, and then cast back after the call:
    Qt Code:
    1. double var1 = 0.0;
    2. double var2 = 0.0;
    3. ...
    4. QVariant pDouble1 = (long)&var1;
    5. QVariant pDouble2 = (long)&var2;
    6. ..
    7. QList<QVariant> varList;
    8. varList << pDouble1 << pDouble 2.... ;
    9. res5 = doSpot->dynamicCall(str5.toLatin1(), varList ); //use the correct signature with pointers!!
    10. double *pVar = varList.at(0);
    11. var1 = *pVar;
    To copy to clipboard, switch view to plain text mode 

    I don't know if this will work, this is just something I would try.
    Last edited by high_flyer; 25th July 2011 at 14:48.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  12. #11
    Join Date
    Jun 2011
    Posts
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Using ActiveX controls and dumpcpp

    hello:
    I use dumpcpp to create a "dospotpc.h" and "dospotpc.cpp" file before: "dumpcpp {74676A0F-BB65-48A0-8044-F453692E9A8A} -o dospotpc"
    In file "dospotpc.h", this function prototype is:
    Qt Code:
    1. inline int doGetMeasureDataEx(int numDev, double& Xo, double& Yo, double& Po);
    To copy to clipboard, switch view to plain text mode 
    so, I use this code to call "dynamicCall()" function:
    Qt Code:
    1. QString str5 = "doGetMeasureDataEx(int, double&, double&, double&)";
    To copy to clipboard, switch view to plain text mode 
    I don't know why the function argument transform from pointer type to reference type.

  13. #12
    Join Date
    Jun 2011
    Posts
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Using ActiveX controls and dumpcpp

    it doesn't seem to work successfully. I try this and get some errors while compile.

Similar Threads

  1. ActiveX - Integrate dumpcpp interfaces
    By durbrak in forum Qt Programming
    Replies: 3
    Last Post: 10th February 2011, 06:54
  2. compilation error when including dumpcpp output
    By Jimmy2775 in forum Qt Programming
    Replies: 13
    Last Post: 14th May 2010, 04:12
  3. Replies: 0
    Last Post: 29th March 2010, 03:46
  4. Hiding controls changes spacing of other controls
    By MrGarbage in forum Qt Programming
    Replies: 1
    Last Post: 18th December 2007, 20:47
  5. Integrating dumpcpp in VS build
    By Jimmy2775 in forum Qt Programming
    Replies: 2
    Last Post: 15th October 2007, 17:48

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.