我使用一些 ATL 函数来创建媒体控件,但似乎我只能使用动态链接到 ATL 选项。当我切换到 ATL 的静态链接时,我无法成功创建控件。
我很混乱。任何人都可以帮助我吗?
这是我的代码:
//related headers
#include <wmp.h>
#include <atlbase.h>
#include <atlcom.h>
#include <atlhost.h>
#include <atlctl.h>
//related vars
CAxWindow m_wndView; // ActiveX host window class. CComPtr<IWMPPlayer>
m_spWMPPlayer; // Smart pointer to IWMPPlayer interface.
//related function code:
CComPtr<IAxWinHostWindow> spHost;
HRESULT hr;
m_wndView.Create(m_hWnd, rect, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN, WS_EX_CLIENTEDGE);
hr = m_wndView.QueryHost(&spHost);
/*
when I switch to "Static Link to ATL" option, I will fail here
E_FAIL == hr;//the failure flag
*/
if(!SUCCEEDED(hr)) return FALSE;
hr = spHost->CreateControl(CComBSTR(_T("{6BF52A52-394A-11d3-B153-00C04F79FAA6}")), m_wndView, 0);
if(!SUCCEEDED(hr)) return FALSE;
hr = m_wndView.QueryControl(&m_spWMPPlayer);
if(!SUCCEEDED(hr)) return FALSE;