在制作OCX时,为什么定义了属性却无法访问,该怎么解决
在制作OCX时,为什么定义了属性却无法访问
已定义了一个属性FetionUser,但即出现“[C++ Error] FetionOCImpl1.cpp(654): E2316 'FetionUser' is not a member of 'TWinControlAccess<TFetionOCX>'”错误,如何解决?
以下是通过界面定义自动生成的代码:
头文件
[code=C/C++]
//$$---- Active Form HDR ---- (stActiveFormHdr)
//---------------------------------------------------------------------------
#ifndef FetionOCImpl1H
#define FetionOCImpl1H
//---------------------------------------------------------------------------
#include <classes.hpp>
#include <controls.hpp>
#include <stdCtrls.hpp>
#include <forms.hpp>
#include "FetionOCProj1_TLB.h"
#include <AxCtrls.hpp>
//---------------------------------------------------------------------------
class TFetionOCX : public TActiveForm
{
__published: // IDE-managed Components
private: // User declarations
public: // User declarations
__fastcall TFetionOCX(HWND ParentWindow);
__fastcall TFetionOCX(TComponent* AOwner): TActiveForm(AOwner) {};
};
//---------------------------------------------------------------------------
extern PACKAGE TFetionOCX *FetionOCX;
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
class ATL_NO_VTABLE TFetionOCXImpl:
VCLCONTROL_IMPL(TFetionOCXImpl, FetionOCX, TFetionOCX, IFetionOCX, DIID_IFetionOCXEvents)
{
void __fastcall ActivateEvent(TObject *Sender);
void __fastcall ClickEvent(TObject *Sender);
void __fastcall CreateEvent(TObject *Sender);
void __fastcall DblClickEvent(TObject *Sender);
void __fastcall DeactivateEvent(TObject *Sender);
void __fastcall DestroyEvent(TObject *Sender);
void __fastcall KeyPressEvent(TObject *Sender, char &Key);
void __fastcall PaintEvent(TObject *Sender);
public:
void InitializeControl()
{
m_VclCtl->OnActivate = ActivateEvent;
m_VclCtl->OnClick = ClickEvent;
m_VclCtl->OnCreate = CreateEvent;
m_VclCtl->OnDblClick = DblClickEvent;
m_VclCtl->OnDeactivate = DeactivateEvent;
m_VclCtl->OnDestroy = DestroyEvent;
m_VclCtl->OnKeyPress = KeyPressEvent;
m_VclCtl->OnPaint = PaintEvent;
}
// The COM MAP entries declares the interfaces your object exposes (through
// QueryInterface). CComRootObjectEx::InternalQueryInterface only returns
// pointers for interfaces in the COM map. VCL controls exposed as OCXes
// have a minimum set of interfaces defined by the
// VCL_CONTROL_COM_INTERFACE_ENTRIES macro. Add other interfaces supported
// by your object with additional COM_INTERFACE_ENTRY[_xxx] macros.
//
BEGIN_COM_MAP(TFetionOCXImpl)
VCL_CONTROL_COM_INTERFACE_ENTRIES(IFetionOCX)
END_COM_MAP()
// The PROPERTY map stores property descriptions, property DISPIDs,
// property page CLSIDs and IDispatch IIDs. You may use use
// IPerPropertyBrowsingImpl, IPersistPropertyBagImpl, IPersistStreamInitImpl,
// and ISpecifyPropertyPageImpl to utilize the information in you property
// map.
//
// NOTE: The BCB Wizard does *NOT* maintain your PROPERTY_MAP table. You must
// add or remove entries manually.
//
BEGIN_PROPERTY_MAP(TFetionOCXImpl)
// PROP_PAGE(CLSID_FetionOCXPage)
END_PROPERTY_MAP()
/* DECLARE_VCL_CONTROL_PERSISTENCE(CppClass, VclClass) is needed for VCL
* controls to persist via the VCL streaming mechanism and not the ATL mechanism.
* The macro adds static IPersistStreamInit_Load and IPersistStreamInit_Save
* methods to your implementation class, overriding the methods in IPersistStreamImpl.
已定义了一个属性FetionUser,但即出现“[C++ Error] FetionOCImpl1.cpp(654): E2316 'FetionUser' is not a member of 'TWinControlAccess<TFetionOCX>'”错误,如何解决?
STDMETHODIMP TFetionOCXImpl::get_FetionUser(BSTR* Value)
{
try
{
*Value = WideString(m_VclCtl->FetionUser).Copy(); //这里出错
}
catch(Exception &e)
{
return Error(e.Message.c_str(), IID_IFetionOCX);
}
return S_OK;
};
以下是通过界面定义自动生成的代码:
头文件
[code=C/C++]
//$$---- Active Form HDR ---- (stActiveFormHdr)
//---------------------------------------------------------------------------
#ifndef FetionOCImpl1H
#define FetionOCImpl1H
//---------------------------------------------------------------------------
#include <classes.hpp>
#include <controls.hpp>
#include <stdCtrls.hpp>
#include <forms.hpp>
#include "FetionOCProj1_TLB.h"
#include <AxCtrls.hpp>
//---------------------------------------------------------------------------
class TFetionOCX : public TActiveForm
{
__published: // IDE-managed Components
private: // User declarations
public: // User declarations
__fastcall TFetionOCX(HWND ParentWindow);
__fastcall TFetionOCX(TComponent* AOwner): TActiveForm(AOwner) {};
};
//---------------------------------------------------------------------------
extern PACKAGE TFetionOCX *FetionOCX;
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
class ATL_NO_VTABLE TFetionOCXImpl:
VCLCONTROL_IMPL(TFetionOCXImpl, FetionOCX, TFetionOCX, IFetionOCX, DIID_IFetionOCXEvents)
{
void __fastcall ActivateEvent(TObject *Sender);
void __fastcall ClickEvent(TObject *Sender);
void __fastcall CreateEvent(TObject *Sender);
void __fastcall DblClickEvent(TObject *Sender);
void __fastcall DeactivateEvent(TObject *Sender);
void __fastcall DestroyEvent(TObject *Sender);
void __fastcall KeyPressEvent(TObject *Sender, char &Key);
void __fastcall PaintEvent(TObject *Sender);
public:
void InitializeControl()
{
m_VclCtl->OnActivate = ActivateEvent;
m_VclCtl->OnClick = ClickEvent;
m_VclCtl->OnCreate = CreateEvent;
m_VclCtl->OnDblClick = DblClickEvent;
m_VclCtl->OnDeactivate = DeactivateEvent;
m_VclCtl->OnDestroy = DestroyEvent;
m_VclCtl->OnKeyPress = KeyPressEvent;
m_VclCtl->OnPaint = PaintEvent;
}
// The COM MAP entries declares the interfaces your object exposes (through
// QueryInterface). CComRootObjectEx::InternalQueryInterface only returns
// pointers for interfaces in the COM map. VCL controls exposed as OCXes
// have a minimum set of interfaces defined by the
// VCL_CONTROL_COM_INTERFACE_ENTRIES macro. Add other interfaces supported
// by your object with additional COM_INTERFACE_ENTRY[_xxx] macros.
//
BEGIN_COM_MAP(TFetionOCXImpl)
VCL_CONTROL_COM_INTERFACE_ENTRIES(IFetionOCX)
END_COM_MAP()
// The PROPERTY map stores property descriptions, property DISPIDs,
// property page CLSIDs and IDispatch IIDs. You may use use
// IPerPropertyBrowsingImpl, IPersistPropertyBagImpl, IPersistStreamInitImpl,
// and ISpecifyPropertyPageImpl to utilize the information in you property
// map.
//
// NOTE: The BCB Wizard does *NOT* maintain your PROPERTY_MAP table. You must
// add or remove entries manually.
//
BEGIN_PROPERTY_MAP(TFetionOCXImpl)
// PROP_PAGE(CLSID_FetionOCXPage)
END_PROPERTY_MAP()
/* DECLARE_VCL_CONTROL_PERSISTENCE(CppClass, VclClass) is needed for VCL
* controls to persist via the VCL streaming mechanism and not the ATL mechanism.
* The macro adds static IPersistStreamInit_Load and IPersistStreamInit_Save
* methods to your implementation class, overriding the methods in IPersistStreamImpl.