Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QAxWidget get pointer to my activeX control

QAxWidget get pointer to my activeX control

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 1.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Tony123
    wrote on last edited by Tony123
    #1

    Hi guys simple question ..maybe :)

    How can I achieve this in Qt:

    // in MFC VC++ project
    CWnd *pdfControl = GetDlgItem( IDC_PDFCREACTIVEX1 );
     ASSERT( pdfControl );
     LPUNKNOWN lpUnknown = pdfControl->GetControlUnknown();
     ASSERT( lpUnknown );
    

    I find this

    ui.myAxWidget.control()
    

    but its return only QString I need LPUNKOWN

    It's really important for me to get pointer to my ActiveX control somehow.

    Thanks in advance

    1 Reply Last reply
    0
    • hskoglundH Offline
      hskoglundH Offline
      hskoglund
      wrote on last edited by
      #2

      Hi, #include "windows.h" and #include "QUuid" and try

      LPUNKNOWN lpUnknown;
      ui.myAxWidget.queryInterface(QUuid(IID_IUnknown),(LPVOID*) &lpUnknown);
      

      Then, to check to really got the correct LPUNKNOWN for your ActiveX control, you can try something like this: (it parties on the LPUNKNOWN above to retrieve some documentation for that ActiveX control)

      LPDISPATCH pDispatch;
      lpUnknown->QueryInterface(IID_IDispatch, (LPVOID*) &pDispatch);
      
      LPTYPEINFO pTypeInfo;
      pDispatch->GetTypeInfo(0,LOCALE_SYSTEM_DEFAULT,&pTypeInfo);
      
      LPTYPELIB pTypeLib;
      UINT uTypeInfoIndex;
      pTypeInfo->GetContainingTypeLib(&pTypeLib,&uTypeInfoIndex);
      
      BSTR bstrName,bstrDocString;
      pTypeLib->GetDocumentation(-1,&bstrName,&bstrDocString,NULL,NULL);
      QString sName((QChar*)bstrName,::SysStringLen(bstrName));
      QString sDocString((QChar*)bstrDocString,::SysStringLen(bstrDocString));
      
      // show what we've got
      qDebug() << sName << sDocString;
      
      1 Reply Last reply
      3
      • T Offline
        T Offline
        Tony123
        wrote on last edited by Tony123
        #3

        Thanks @hskoglund for reply.
        When I type it like this:

        	LPUNKNOWN lpUnknown;
        	long lo = ui.axWidget->queryInterface(QUuid(ui.axWidget->control()), (LPVOID*)&lpUnknown);
        

        lpUknown is null.

        Thanks in advance!

        1 Reply Last reply
        0
        • hskoglundH Offline
          hskoglundH Offline
          hskoglund
          wrote on last edited by hskoglund
          #4

          Well that's because ->queryInterface() expects an Interface-flavored UUID, for example IID_IUnknown or IID_IDispatch etc. These are stored in the registry in the HKEY_CLASSES_ROOT\Interface part. You can use either IID_IUnknown as in my example above, or use its string representation like this:
          long lo = ui.axWidget->queryInterface(QUuid("{00000000-0000-0000-c000-000000000046}"), (LPVOID*)&lpUnknown);

          But using a CLSID-flavored UUID, like in your ...ui.axWidget->control())... example above, will fail and return the HRESULT 0x80004002 (No such interface supported)

          Yeah, so there are many types of different UUIDs used in COM, you can read more here

          1 Reply Last reply
          2

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved