| 1549 | |
| 1550 | |
| 1551 | IObject *GuiType::ControlGetActiveX(HWND aWnd) |
| 1552 | { |
| 1553 | typedef HRESULT (WINAPI *MyAtlAxGetControl)(HWND h, IUnknown **p); |
| 1554 | static MyAtlAxGetControl fnAtlAxGetControl = NULL; |
| 1555 | if (!fnAtlAxGetControl) |
| 1556 | if (HMODULE hmodAtl = GetModuleHandle(_T("atl"))) // GuiType::AddControl should have already permanently loaded it. |
| 1557 | fnAtlAxGetControl = (MyAtlAxGetControl)GetProcAddress(hmodAtl, "AtlAxGetControl"); |
| 1558 | if (fnAtlAxGetControl) // Should always be non-NULL if aControl is actually an ActiveX control. |
| 1559 | { |
| 1560 | IUnknown *punk; |
| 1561 | if (SUCCEEDED(fnAtlAxGetControl(aWnd, &punk))) |
| 1562 | { |
| 1563 | IObject *pobj; |
| 1564 | IDispatch *pdisp; |
| 1565 | if (SUCCEEDED(punk->QueryInterface(IID_IDispatch, (void **)&pdisp))) |
| 1566 | { |
| 1567 | punk->Release(); |
| 1568 | if ( !(pobj = new ComObject(pdisp)) ) |
| 1569 | pdisp->Release(); |
| 1570 | } |
| 1571 | else |
| 1572 | { |
| 1573 | if ( !(pobj = new ComObject((__int64)punk, VT_UNKNOWN)) ) |
| 1574 | punk->Release(); |
| 1575 | } |
| 1576 | return pobj; |
| 1577 | } |
| 1578 | } |
| 1579 | return NULL; |
| 1580 | } |
| 1581 | |
| 1582 | |
| 1583 | STDMETHODIMP IObjectComCompatible::QueryInterface(REFIID riid, void **ppv) |
nothing calls this directly
no test coverage detected