描述:
我用VC开发ACTIVEX向导开发控件,我想在控件中动态生成Media player控件.为什么这样代码会出现错误.请各位帮一下忙.
BOOL CDfgdfApp::InitInstance()
{
BOOL bInit = COleControlModule::InitInstance();
if (bInit)
{
// TODO: Add your own module initialization code here.
AtlAxWinInit();
}
return bInit;
}
int CDfgdfCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (COleControl::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
CAxWindow m_wndView;
CComPtr<IWMPPlayer> m_spWMPPlayer;
CComPtr<IAxWinHostWindow> spHost;
CComPtr<IConnectionPointContainer> spConnectionContainer;
HRESULT hr;
m_wndView.Create(m_hWnd,CRect(0,0,300,200), NULL, WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN, WS_EX_CLIENTEDGE);
hr = m_wndView.QueryHost(&spHost);
hr = spHost->CreateControl(CComBSTR(_T("{6BF52A52-394A-11d3-B153-00C04F79FAA6}")), m_wndView, 0);
hr = m_wndView.QueryControl(&m_spWMPPlayer);
return 0;
}
错误信息如下
C:\11\dfgdf\dfgdf.cpp(31) : error C2065: 'AtlAxWinInit' : undeclared identifier
DfgdfCtl.cpp
C:\11\dfgdf\DfgdfCtl.cpp(202) : error C2065: 'CAxWindow' : undeclared identifier
C:\11\dfgdf\DfgdfCtl.cpp(202) : error C2146: syntax error : missing ';' before identifier 'm_wndView'
C:\11\dfgdf\DfgdfCtl.cpp(202) : error C2065: 'm_wndView' : undeclared identifier
C:\11\dfgdf\DfgdfCtl.cpp(203) : error C2065: 'CComPtr' : undeclared identifier
C:\11\dfgdf\DfgdfCtl.cpp(203) : error C2065: 'IWMPPlayer' : undeclared identifier
C:\11\dfgdf\DfgdfCtl.cpp(203) : error C2065: 'm_spWMPPlayer' : undeclared identifier
C:\11\dfgdf\DfgdfCtl.cpp(203) : warning C4804: '>' : unsafe use of type 'bool' in operation
C:\11\dfgdf\DfgdfCtl.cpp(203) : warning C4552: '>' : operator has no effect; expected operator with side-effect
C:\11\dfgdf\DfgdfCtl.cpp(205) : error C2065: 'IAxWinHostWindow' : undeclared identifier
C:\11\dfgdf\DfgdfCtl.cpp(205) : error C2065: 'spHost' : undeclared identifier
C:\11\dfgdf\DfgdfCtl.cpp(205) : warning C4804: '>' : unsafe use of type 'bool' in operation
C:\11\dfgdf\DfgdfCtl.cpp(205) : warning C4552: '>' : operator has no effect; expected operator with side-effect
C:\11\dfgdf\DfgdfCtl.cpp(206) : error C2275: 'IConnectionPointContainer' : illegal use of this type as an expression
c:\program files\microsoft visual studio\vc98\include\ocidl.h(947) : see declaration of 'IConnectionPointContainer'
C:\11\dfgdf\DfgdfCtl.cpp(206) : error C2065: 'spConnectionContainer' : undeclared identifier
C:\11\dfgdf\DfgdfCtl.cpp(208) : error C2228: left of '.Create' must have class/struct/union type
C:\11\dfgdf\DfgdfCtl.cpp(209) : error C2228: left of '.QueryHost' must have class/struct/union type
C:\11\dfgdf\DfgdfCtl.cpp(210) : error C2227: left of '->CreateControl' must point to class/struct/union
C:\11\dfgdf\DfgdfCtl.cpp(210) : error C2065: 'CComBSTR' : undeclared identifier
C:\11\dfgdf\DfgdfCtl.cpp(211) : error C2228: left of '.QueryControl' must have class/struct/union type
Generating Code...
Error executing cl.exe.
dfgdf.ocx - 16 error(s), 4 warning(s)