VC6 ATL 控件编译问题:

tematch 2016-03-10 07:12:49
我这边创建了一个 控件类:

class ATL_NO_VTABLE COnePlayerEx :
public CComObjectRootEx<CComSingleThreadModel>,
public CStockPropImpl<COnePlayerEx, IOnePlayerEx, &IID_IOnePlayerEx, &LIBID_ONEPLAYERLib>,
public CComControl<COnePlayerEx>,
public IPersistStreamInitImpl<COnePlayerEx>,
public IOleControlImpl<COnePlayerEx>,
public IOleObjectImpl<COnePlayerEx>,
public IOleInPlaceActiveObjectImpl<COnePlayerEx>,
public IViewObjectExImpl<COnePlayerEx>,
public IOleInPlaceObjectWindowlessImpl<COnePlayerEx>,
public IConnectionPointContainerImpl<COnePlayerEx>,
public IPersistStorageImpl<COnePlayerEx>,
public ISpecifyPropertyPagesImpl<COnePlayerEx>,
public IQuickActivateImpl<COnePlayerEx>,
public IDataObjectImpl<COnePlayerEx>,
public IProvideClassInfo2Impl<&CLSID_OnePlayerEx, &DIID__IOnePlayerExEvents, &LIBID_ONEPLAYERLib>,
public IPropertyNotifySinkCP<COnePlayerEx>,
public CComCoClass<COnePlayerEx, &CLSID_OnePlayerEx>,
public CProxy_IOnePlayerExEvents< COnePlayerEx >,
public IObjectSafetyImpl<COnePlayerEx, INTERFACESAFE_FOR_UNTRUSTED_CALLER | INTERFACESAFE_FOR_UNTRUSTED_DATA>

然后在另外一个文件FullWnd.h 里创建了另外一个对话框类CFullWnd:

class COnePlayerEx;
class CFullWnd : public CDialogImpl<CFullWnd>
{
public:
BEGIN_MSG_MAP( CFullWnd )
MESSAGE_HANDLER(WM_SIZE, OnSize)
MESSAGE_HANDLER(WM_SHOWWINDOW,OnShow)
MESSAGE_HANDLER(WM_KEYUP, OnKeyUp)
MESSAGE_HANDLER(WM_PAINT, OnPaint)
END_MSG_MAP()

public:
CFullWnd();
virtual ~CFullWnd();
enum {IDD=IDD_DIALOG_FULL};
public:
COnePlayerEx* m_pOne;

在CFullWnd 类中要使用 m_pOne 这个指针,代码编译的时候总是报错如下:
E:\TMC_Coding\Src\OnePlayer\VideoWndProc.cpp(277) : error C2027: use of undefined type 'COnePlayerEx'
E:\TMC_Coding\Src\OnePlayer\VideoWndProc.h(18) : see declaration of 'COnePlayerEx'
E:\TMC_Coding\Src\OnePlayer\VideoWndProc.cpp(277) : error C2227: left of '->m_bFullScreen' must point to class/struct/union
E:\TMC_Coding\Src\OnePlayer\VideoWndProc.cpp(282) : error C2027: use of undefined type 'COnePlayerEx'
E:\TMC_Coding\Src\OnePlayer\VideoWndProc.h(18) : see declaration of 'COnePlayerEx'
E:\TMC_Coding\Src\OnePlayer\VideoWndProc.cpp(282) : error C2227: left of '->m_hWnd' must point to class/struct/union

本来想着在FullWnd.h中添加OnePlayerEx.h 行了,但是一加入这个头文件就报错:
E:\TMC_Coding\Src\OnePlayer\OnePlayerCP.h(9) : error C2065: 'DIID__IOnePlayerExEvents' : undeclared identifier
E:\TMC_Coding\Src\OnePlayer\OnePlayerCP.h(94) : see reference to class template instantiation 'CProxy_IOnePlayerExEvents<T>' being compiled
E:\TMC_Coding\Src\OnePlayer\OnePlayerEx.h(16) : error C2065: 'IOnePlayerEx' : undeclared identifier
E:\TMC_Coding\Src\OnePlayer\OnePlayerEx.h(16) : error C2065: 'IID_IOnePlayerEx' : undeclared identifier
E:\TMC_Coding\Src\OnePlayer\OnePlayerEx.h(16) : error C2065: 'LIBID_ONEPLAYERLib' : undeclared identifier
E:\TMC_Coding\Src\OnePlayer\OnePlayerEx.h(29) : error C2065: 'CLSID_OnePlayerEx' : undeclared identifier
E:\TMC_Coding\Src\OnePlayer\OnePlayerCP.h(10) : fatal error C1903: unable to recover from previous error(s); stopping compilation

这个是什么原因啊?

...全文
104 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
redui 2016-03-10
  • 打赏
  • 举报
回复
那些GUID的定义头文件你也需要包括啊
tematch 2016-03-10
  • 打赏
  • 举报
回复
把两个头文件贴出来,如下: class ATL_NO_VTABLE COnePlayerEx : public CComObjectRootEx<CComSingleThreadModel>, public CStockPropImpl<COnePlayerEx, IOnePlayerEx, &IID_IOnePlayerEx, &LIBID_ONEPLAYERLib>, public CComControl<COnePlayerEx>, public IPersistStreamInitImpl<COnePlayerEx>, public IOleControlImpl<COnePlayerEx>, public IOleObjectImpl<COnePlayerEx>, public IOleInPlaceActiveObjectImpl<COnePlayerEx>, public IViewObjectExImpl<COnePlayerEx>, public IOleInPlaceObjectWindowlessImpl<COnePlayerEx>, public IConnectionPointContainerImpl<COnePlayerEx>, public IPersistStorageImpl<COnePlayerEx>, public ISpecifyPropertyPagesImpl<COnePlayerEx>, public IQuickActivateImpl<COnePlayerEx>, public IDataObjectImpl<COnePlayerEx>, public IProvideClassInfo2Impl<&CLSID_OnePlayerEx, &DIID__IOnePlayerExEvents, &LIBID_ONEPLAYERLib>, public IPropertyNotifySinkCP<COnePlayerEx>, public CComCoClass<COnePlayerEx, &CLSID_OnePlayerEx>, public CProxy_IOnePlayerExEvents< COnePlayerEx >, public IObjectSafetyImpl<COnePlayerEx, INTERFACESAFE_FOR_UNTRUSTED_CALLER | INTERFACESAFE_FOR_UNTRUSTED_DATA> { public: COnePlayerEx() { m_bWindowOnly = TRUE; //CalcExtent(m_sizeExtent); m_bFullScreen = false; m_oldParent = NULL; } DECLARE_REGISTRY_RESOURCEID(IDR_ONEPLAYEREX) DECLARE_PROTECT_FINAL_CONSTRUCT() BEGIN_COM_MAP(COnePlayerEx) COM_INTERFACE_ENTRY(IOnePlayerEx) COM_INTERFACE_ENTRY(IDispatch) COM_INTERFACE_ENTRY(IViewObjectEx) COM_INTERFACE_ENTRY(IViewObject2) COM_INTERFACE_ENTRY(IViewObject) COM_INTERFACE_ENTRY(IOleInPlaceObjectWindowless) COM_INTERFACE_ENTRY(IOleInPlaceObject) COM_INTERFACE_ENTRY2(IOleWindow, IOleInPlaceObjectWindowless) COM_INTERFACE_ENTRY(IOleInPlaceActiveObject) COM_INTERFACE_ENTRY(IOleControl) COM_INTERFACE_ENTRY(IOleObject) COM_INTERFACE_ENTRY(IPersistStreamInit) COM_INTERFACE_ENTRY2(IPersist, IPersistStreamInit) COM_INTERFACE_ENTRY(IConnectionPointContainer) COM_INTERFACE_ENTRY(ISpecifyPropertyPages) COM_INTERFACE_ENTRY(IQuickActivate) COM_INTERFACE_ENTRY(IPersistStorage) COM_INTERFACE_ENTRY(IDataObject) COM_INTERFACE_ENTRY(IProvideClassInfo) COM_INTERFACE_ENTRY(IProvideClassInfo2) COM_INTERFACE_ENTRY_IMPL(IConnectionPointContainer) COM_INTERFACE_ENTRY(IProvideClassInfo) COM_INTERFACE_ENTRY(IProvideClassInfo2) COM_INTERFACE_ENTRY(IObjectSafety) END_COM_MAP() BEGIN_PROP_MAP(COnePlayerEx) PROP_DATA_ENTRY("_cx", m_sizeExtent.cx, VT_UI4) PROP_DATA_ENTRY("_cy", m_sizeExtent.cy, VT_UI4) PROP_ENTRY("BackColor", DISPID_BACKCOLOR, CLSID_StockColorPage) // Example entries // PROP_ENTRY("Property Description", dispid, clsid) // PROP_PAGE(CLSID_StockColorPage) END_PROP_MAP() BEGIN_CONNECTION_POINT_MAP(COnePlayerEx) CONNECTION_POINT_ENTRY(IID_IPropertyNotifySink) CONNECTION_POINT_ENTRY(DIID__IOnePlayerExEvents) END_CONNECTION_POINT_MAP() BEGIN_MSG_MAP(COnePlayerEx) CHAIN_MSG_MAP(CComControl<COnePlayerEx>) DEFAULT_REFLECTION_HANDLER() MESSAGE_HANDLER(WM_CREATE, OnCreate) MESSAGE_HANDLER(WM_KEYDOWN, OnKeyDown) MESSAGE_HANDLER(WM_KEYUP, OnKeyUp) MESSAGE_HANDLER(WM_LBUTTONDBLCLK, OnLButtonDblClk) MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown) MESSAGE_HANDLER(WM_LBUTTONUP, OnLButtonUP) MESSAGE_HANDLER(WM_MOUSEACTIVATE, OnMouseActivate) MESSAGE_HANDLER(WM_MOUSEMOVE, OnMouseMove) MESSAGE_HANDLER(WM_MOUSEWHEEL, OnMouseWheel) MESSAGE_HANDLER(WM_PAINT, OnPaint) MESSAGE_HANDLER(WM_RBUTTONDOWN, OnRButtonDown) MESSAGE_HANDLER(WM_RBUTTONUP, OnRButtonUp) MESSAGE_HANDLER(WM_SETCURSOR, OnSetCursor) MESSAGE_HANDLER(WM_SHOWWINDOW, OnShowWindow) MESSAGE_HANDLER(WM_SIZE, OnSize) MESSAGE_HANDLER(WM_TIMER, OnTimer) END_MSG_MAP() // Handler prototypes: // LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); // LRESULT CommandHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); // LRESULT NotifyHandler(int idCtrl, LPNMHDR pnmh, BOOL& bHandled); // IViewObjectEx DECLARE_VIEW_STATUS(VIEWSTATUS_SOLIDBKGND | VIEWSTATUS_OPAQUE) // IOnePlayerEx public: STDMETHOD(DoMessage)(/*[in]*/ int messagetype, /*[in]*/ BSTR inputxml, /*[in]*/ BSTR *outputxml); STDMETHOD(StopOCX)(/*[in]*/ BSTR inputxml, /*[out,retval]*/ BSTR *outputxml); STDMETHOD(InitAnvoOcx)(/*[in]*/BSTR serverip, /*[in]*/ int port,/*[in]*/ BSTR inputxml, /*[out,retval]*/ BSTR *outputxml); STDMETHOD(add)(/*[in]*/int a,/*[in]*/ int b,/*[out,retval]*/int *c); static void CALLBACK Notify(int msgtype, CData xmldata,void* userData); HRESULT OnDraw(ATL_DRAWINFO& di) { return S_OK; } LRESULT OnShowWindow(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { LOG_INFO("---------------OnShowWindow "); UpdateBackWnd(this->m_hWnd); return S_OK; } LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnKeyDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnKeyUp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnLButtonDblClk(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnLButtonDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnLButtonUP(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnMouseActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnMouseMove(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnMouseWheel(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnRButtonDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnRButtonUp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnSetCursor(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); CVideoWndProc m_videoWnd; CFullWnd m_fullscreenWnd; }; 另外一个头文件: class COnePlayerEx; class CFullWnd : public CDialogImpl<CFullWnd> { public: BEGIN_MSG_MAP( CFullWnd ) MESSAGE_HANDLER(WM_PAINT, OnPaint) END_MSG_MAP() public: CFullWnd(); virtual ~CFullWnd(); enum {IDD=IDD_DIALOG_FULL}; public: void SetOwner(COnePlayerEx * ptr) { m_pOne= ptr; } public: LRESULT OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); public: COnePlayerEx *m_pOne; };

703

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder ActiveX/COM/DCOM
社区管理员
  • ActiveX/COM/DCOM社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧