I have a standard MFC MDI app and I am trying to use an ATL window to create a WMP ActiveX control. But, things are failing before I get that far. In my code, I create a typical CWnd window. In't it's OnCreate method, I have this code:
if (CWnd::OnCreate(lpCreateStruct) == -1) return -1; RECT rect; GetClientRect(&rect); AtlAxWinInit(); HWND hWnd = m_wndView.Create(m_hWnd, rect, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN, WS_EX_CLIENTEDGE); CComPtr<IAxWinHostWindow> spHost; HRESULT hr = m_wndView.QueryHost(&spHost); <== FAILS HERE!
hr = spHost->CreateControl(CComBSTR(_T("{6BF52A52-394A-11d3-B153-00C04F79FAA6}")), m_wndView, 0); hr = m_wndView.QueryControl(&m_spWMPPlayer);
The HRESULT returned by m_wndView.QueryHost(&spHost) is E_FAIL for some reason. I got this example straight from MSDN. m_wndView is a defined as "CAxWindow m_wndView" in my class.
Do I need to enable some aspect of ATL to get this to work?
The Hinged Newt