自制组件出错!请高手帮忙!
我从StringGrid继承自制MyDBGrid组件代码如下:
MyDBGrid.h:
//---------------------------------------------------------------------------
#ifndef MyDBGridH
#define MyDBGridH
//---------------------------------------------------------------------------
#include <SysUtils.hpp>
#include <Classes.hpp>
#include <Controls.hpp>
#include <Grids.hpp>
#include <ADODB.hpp>
//---------------------------------------------------------------------------
class PACKAGE TMyDBGrid : public TStringGrid
{
private:
TADOQuery *MasterData;
void __fastcall SetMasterData(TADOQuery *MasterDataSet);
TADOQuery *DetailData;
void __fastcall SetDetailData(TADOQuery *DetailDataSet);
protected:
public:
__fastcall TMyDBGrid(TComponent* Owner);
__published:
__property TADOQuery *MasterDataSet={write=SetMasterData};
__property TADOQuery *DetailDataSet={write=SetDetailData};
};
//---------------------------------------------------------------------------
#endif
MyDBGrid.cpp:
#include <vcl.h>
#pragma hdrstop
#include "MyDBGrid.h"
#pragma package(smart_init)
//---------------------------------------------------------------------------
// ValidCtrCheck is used to assure that the components created do not have
// any pure virtual functions.
//
static inline void ValidCtrCheck(TMyDBGrid *)
{
new TMyDBGrid(NULL);
}
//---------------------------------------------------------------------------
__fastcall TMyDBGrid::TMyDBGrid(TComponent* Owner)
: TStringGrid(Owner)
{
}
//---------------------------------------------------------------------------
namespace Mydbgrid
{
void __fastcall PACKAGE Register()
{
TComponentClass classes[1] = {__classid(TMyDBGrid)};
RegisterComponents("MyComponent", classes, 0);
}
}
//---------------------------------------------------------------------------
void __fastcall TMyDBGrid::SetMasterData(TADOQuery *MasterDataSet)
{
MasterData=MasterDataSet;
}
//---------------------------------------------------------------------------
void __fastcall TMyDBGrid::SetDetailData(TADOQuery *DetailDataSet)
{
DetailData=DetailDataSet;
}
安装了以后将控件拖放到窗口时出错:
Access violation at address 4000685E in module 'RTL60.BPL'.Read of address 7FFFFFF8.
再次拖放出错:
A field or method named MyDGBrid1 already exists.
Package窗口,adortl.bpi、dbrtl.bpi、rtl.bpi、vcl.bpi均不能打开提示:
File adortl.bpk not found
...
请问是什么问题?