PDA

View Full Version : QAxServer. How to embed QWidget into .NET forrm?



ivigasin
21st May 2012, 19:35
I try to embed ActiveQt sample into .NET form. The sample is QT_HOME\examples\activeqt\multiple (however the same situation is with any sample).

The sample builds fine and works in IE and ActiveX Control Test Container. However when dragging it to a form the following error occurs:

Failed to create component AxHost. The error message follows: 'System.Runtime.InteropServices.COMException (0x8002801D)': Library not registered. (Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED)) at
.... .NET stack trace follows.............

Applies both to VS2008 and VS2010. Qt 4.7.4 and Qt 4.8.1.

Does anyone knows how to resolve this issue? Thanks in advance.

Kind regards, Ivan

d_d_v
28th November 2012, 17:15
Hi!

I tried the same but into the most simple MFC application with VS2008 and it crashed!

I wonder if anyone has already succeeded in using a QT activeX in a non-QT application?

ChrisW67
29th November 2012, 05:33
Yes, it does work. I have seen some of the examples working embedded in Internet Explorer (as has the OP).

Since neither of you has told us what you have actually done to make this work I will just guess:

The DLL output from your project build has to be registered with Windows using regsvr32. This is standard Active X/COM stuff and not Qt specific.
The DLL cannot be registered if it cannot load, and to do that the necessary Qt and C++ runtime libraries have to somewhere Windows can find them when it loads the DLL. If the DLL requires Qt plugins these must also be present. None of this is any different to deploying any Qt program on Windows and is covered in the docs and this forum routinely.

d_d_v
29th November 2012, 10:42
Here is how I proceed:
- The directory containing the qt dlls is in the PATH
- I build the qt example 'activeqt/simple' in VS2008 (launched from the 'Visual Studio with Qt 4.8.2' shortcut)
- I registered the COM server with the cmd 'simpleax.exe /regserver'
- In VS2008 (normal mode, not launched from Visual Studio with Qt 4.8.2 shortcut), I create a new MFC dialog-based application, with the "ActiveX controls" option checked on
- in the main dialog resource view, I right-click and select the "Insert ActiveX control" menu item
- In the "Insert ActiveX control" window list, I select the "QSimpleAX Class" item, and validate the dialog
- There is a white window displayed now in the resource view
- I launch the MFC application in debug mode: a failed assertion occurs in atlmfc\src\mfc\occcont.cpp:

HWND hwndCtrl=AfxGetDlgItemStartFromHWND(pOccDlgInfo->m_pItemInfo[i].nId, hwndSearchFrom);
//If not found, revert to prev method of GetDlgItem, this means Win32 children list and
//resource item array are out of sync
if (hwndCtrl == NULL)
{
hwndCtrl = ::GetDlgItem(m_pWnd->GetSafeHwnd(),pOccDlgInfo->m_pItemInfo[i].nId);
TRACE(traceAppMsg, 0, "Warning: Resource items and Win32 Z-order lists are out of sync. Tab order may be not defined well.\n");
}
COleControlSiteOrWnd *pTemp =
new COleControlSiteOrWnd(
hwndCtrl,
pOccDlgInfo->m_pItemInfo[i].bAutoRadioButton);
ASSERT(IsWindow(pTemp->m_hWnd)); <===== H E R E

I note that hwndCtrl is NULL

If I launch the "ActiveX Control Test Container" application provided in the C++ samples with VS2008, I can insert this activex with no problem, while this application is also a MFC application!

In my basic MFC dialog-based application, I tried to insert other well known activex, like "adobe pdf reader", and "microsoft office spreadsheet", both worked.

So what could be wrong?

Thanks