I try create my own components :Tbinarytable
but if I use property editor for property
String FileName all work good but if I click on Butto1 Builder Cancel all work and return to windows. Here is my source code:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "TATable.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(TBTable *)
{
new TBTable(NULL);
}
//---------------------------------------------------------------------------
__fastcall TBTable::TBTable(TComponent* Owner)
: TComponent(Owner)
{
FList=new TList();
FFileName="Text.bds";
}
//---------------------------------------------------------------------------
namespace Tatable
{
void __fastcall PACKAGE Register()
{
TComponentClass classes[1] = {__classid(TBTable)};
RegisterComponents("Data Access", classes, 0);
RegisterPropertyEditor(AnsiStringTypeInfo(),__clas sid(TBTable) ,"FileName", __classid(TFileNameProperty));
RegisterPropertyEditor(__typeinfo(TbField),__class id(TBTable) ,"FItem", __classid(TFItemProperty));
}
}
//---------------------------------------------------------------------------
TTypeInfo* AnsiStringTypeInfo()
{
TTypeInfo* typeInfo = new TTypeInfo;
typeInfo->Name = "AnsiString";
typeInfo->Kind = tkLString;
return typeInfo;
}
TPropertyAttributes __fastcall TFileNameProperty::GetAttributes(void)
{
return TPropertyAttributes() << paDialog << paAutoUpdate;
}
void __fastcall TFileNameProperty::Edit()
{
Application->CreateForm(__classid(TForm2) , &Form2);
Form2->Caption = GetName();
Form2->ShowModal();
SetStrValue(Form2->Edit1->Text);
}
TPropertyAttributes __fastcall TFItemProperty::GetAttributes(void)
{
return TPropertyAttributes() << paSubProperties << paDialog;
}
void __fastcall TFItemProperty::Edit()
{
Application->CreateForm(__classid(TForm1), &Form1);
GetOrdValue();
Form1->ShowModal();
SetOrdValue(0);
SetStrValue("Set Value");
}
void __fastcall TBTable::SetFileName(String f)
{
FileName=f;
}
void __fastcall TBTable::SetField(TbField *F)
{
FList=Form1->FList;
Head0.FCount=FList->Count;
}
//---------------------------------------------------------------------------
#ifndef TATableH
#define TATableH
//---------------------------------------------------------------------------
#include <SysUtils.hpp>
#include <Controls.hpp>
#include <Classes.hpp>
#include <Forms.hpp>
#include <io.h>
#include <db.hpp>
#include <dsgnintf.hpp>
#include "unit1.h"
#include "unit2.h"
#pragma link "unit1.obj"
#pragma link "unit2.obj"
//---------------------------------------------------------------------------
TTypeInfo* AnsiStringTypeInfo();
class PACKAGE TFileNameProperty : public TStringProperty
{
TPropertyAttributes __fastcall GetAttributes(void);
void __fastcall Edit(void);
};
class PACKAGE TFItemProperty : public TClassProperty
{
TPropertyAttributes __fastcall GetAttributes(void);
void __fastcall Edit(void);
};
class PACKAGE TbField : TPersistent
{
AnsiString FName;
AnsiString FDispNam;
Byte FType;
Byte FSize;
Byte FPrecision;
Byte FNo;
bool Frequired;
Byte FoFset;
AnsiString AsString;
Variant Value;
};
struct
{
unsigned long Recno;
unsigned long Position;
Word FSize;
Byte Stat; // N normal,D delete,X na vymazanie,F patri do Indexu
Byte OffSet[];
}HRec;
class PACKAGE TRecHlav : public TList
{
void __fastcall LoadFromFile(void);
void __fastcall SavetoFile(void);
};
int __fastcall Zorad(void *i1,void *i2);
struct
{
unsigned int HSize;
char *ID;
unsigned long B_Pos;
unsigned long RecCount;
unsigned long CurRec;
unsigned long CurPos;
int FCount;
Byte FSize0;
bool Bof,Eof;
}Head0;
class PACKAGE TBTable : public TComponent
{
private:
bool FActive;
int Fdb;
TMemoryStream *RBufN;
TMemoryStream *RCurr;
void __fastcall SetFileName(String FileName);
void __fastcall SetfValue(AnsiString Name,Variant V);
Variant * __fastcall GetfValue(AnsiString Name);
void __fastcall SetNValue(int Index,Variant V);
Variant * __fastcall GetNValue(int Index);
void __fastcall SetField(TbField *F);
TbField *FbField;
String FFileName;
protected:
TRecHlav *RCH;
public:
TList *FList;
bool __fastcall Open(void);
bool __fastcall Writehlav(void);
bool __fastcall ReadHlav(void);
int __fastcall ClearBuffer(void);
int __fastcall GoTo(int Recno);
int __fastcall ReadBuffer(void);
int __fastcall WriteBuffer(bool New);
__fastcall TBTable(TComponent* Owner);
__property Variant FName[AnsiString Name]={read=GetfValue,write=SetfValue};
__published:
__property bool Active = {read=FActive,write=FActive};
__property String FileName={read=FFileName,write=SetFileName};
__property TbField *FBField={read=FbField,write=SetField};
};
//---------------------------------------------------------------------------
#endif
and code for filename property editor:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit2.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm2 *Form2;
//---------------------------------------------------------------------------
__fastcall TForm2::TForm2(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm2::Button1Click(TObject *Sender)
{
Form2->Close();
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
#ifndef Unit2H
#define Unit2H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <FileCtrl.hpp>
//---------------------------------------------------------------------------
class TForm2 : public TForm
{
__published: // IDE-managed Components
TDriveComboBox *DriveComboBox1;
TDirectoryListBox *DirectoryListBox1;
TFileListBox *FileListBox1;
TFilterComboBox *FilterComboBox1;
TEdit *Edit1;
TButton *Button1;
void __fastcall Button1Click(TObject *Sender);
private: // User declarations
public: // User declarations
__fastcall TForm2(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm2 *Form2;
//---------------------------------------------------------------------------
#endif
thank veri much for any help Bye.
Edited by WingedPanther, 21 May 2010 - 07:02 AM.
add code tags (the # button)


Sign In
Create Account


Back to top









