我使用一些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;
当静态链接到ATL时,您必须使用预处理器:_ATL_DLL,
Property Pages | C/c++ | Preprocessor