这不是一个组件,是我写的一个类,但是在单元初始化中,创建了该类的实例。
在Delphi中我写的系统一般都是使用动态装载包,包中放有Form。下面是一个例子:
unit AppinfUnit;
{$J+}
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, BaseUnitA, ComCtrls, dxtree, DB, dxLayoutControl, dxExEdtr,
dxEdLib, dxDBELib, dxCntner, dxEditor, dxDBTLCl, dxGrClms, dxTL,
dxDBCtrl, dxDBGrid, KsThemeEngine, KsHooks, KsForms, KsThemeForms,
KsMessages, KsThemeMessages, ImgList, StdActns, ActnList, DBClient,
PubDataSet, AutoDataSet, dxLayoutLookAndFeels, Menus, ToolWin, cxControls,
KsControls, KsButtons, KsThemeButtons, KsItems, KsThemeItems, KsMenus,
KsThemeMenus, dxInspRw, dxDBInRw, dxDBInsp, dxInspct;
type
TAppinf = class(TBaseFmt)
MainDataAPP_ID: TStringField;
MainDataAPP_NM: TStringField;
MainDataAPP_ST: TFMTBCDField;
MainDataAPP_RG: TFMTBCDField;
MainDataAPP_VR: TStringField;
MainDataAPP_RF: TBlobField;
MainDataAPP_IC: TBlobField;
MainDataAPP_DA: TBlobField;
dxLayoutControl1Group1: TdxLayoutGroup;
dxLayoutControl1Group3: TdxLayoutGroup;
ImageList2: TImageList;
dxTreeView1: TdxTreeView;
dxLayoutControl1Item1: TdxLayoutItem;
dxDBInspector1: TdxDBInspector;
dxLayoutControl1Item3: TdxLayoutItem;
dxDBInspector1APP_ID: TdxInspectorDBMaskRow;
dxDBInspector1APP_NM: TdxInspectorDBMaskRow;
dxDBInspector1APP_VR: TdxInspectorDBMaskRow;
dxDBInspector1APP_IC: TdxInspectorDBGraphicRow;
dxDBInspector1APP_ST: TdxInspectorDBButtonRow;
dxDBInspector1APP_RG: TdxInspectorDBButtonRow;
dxDBInspector1APP_RF: TdxInspectorDBMemoRow;
dxDBInspector1Row8: TdxInspectorDBButtonRow;
dxDBInspector1Row9: TdxInspectorDBRow;
dxDBInspector1Row10: TdxInspectorDBRow;
dxDBInspector1Row11: TdxInspectorDBRow;
dxLayoutControl1Group2: TdxLayoutGroup;
dxDBGrid1: TdxDBGrid;
dxLayoutControl1Item2: TdxLayoutItem;
dxDBGrid1APP_ID: TdxDBGridMaskColumn;
dxDBGrid1APP_NM: TdxDBGridMaskColumn;
dxDBGrid1APP_ST: TdxDBGridColumn;
dxDBGrid1APP_RG: TdxDBGridColumn;
dxDBGrid1APP_VR: TdxDBGridMaskColumn;
dxDBGrid1APP_RF: TdxDBGridColumn;
dxDBGrid1APP_IC: TdxDBGridGraphicColumn;
dxDBGrid1APP_DA: TdxDBGridColumn;
dxLayoutControl1Group5: TdxLayoutGroup;
procedure dxDBGraphicEdit1GetGraphicClass(Sender: TObject;
var GraphicClass: TGraphicClass);
procedure dxDBGrid1APP_ICGetGraphicClass(Sender: TObject;
Node: TdxTreeListNode
var GraphicClass: TGraphicClass);
procedure MainDataAfterOpen(DataSet: TDataSet);
procedure MainDataAfterScroll(DataSet: TDataSet);
procedure dxTreeView1Change(Sender: TObject
Node: TTreeNode);
procedure dxTreeView1Changing(Sender: TObject
Node: TTreeNode;
var AllowChange: Boolean);
procedure dxDBInspector1APP_STButtonClick(Sender: TObject;
AbsoluteIndex: Integer);
procedure dxDBInspector1APP_RGButtonClick(Sender: TObject;
AbsoluteIndex: Integer);
procedure dxDBInspector1Row8ButtonClick(Sender: TObject;
AbsoluteIndex: Integer);
procedure MainSourceStateChange(Sender: TObject);
procedure MainDataBeforeEdit(DataSet: TDataSet);
private
{ Private declarations }
public
{ Public declarations }
end;
implementation
uses cvlanguage, AppSetUnit, AppSecurityUnit, DesignUnit;
{$R *.dfm}
procedure TAppinf.dxDBGraphicEdit1GetGraphicClass(Sender: TObject;
var GraphicClass: TGraphicClass);
begin
inherited;
GraphicClass:=TIcon;
end;
procedure TAppinf.dxDBGrid1APP_ICGetGraphicClass(Sender: TObject;
Node: TdxTreeListNode
var GraphicClass: TGraphicClass);
begin
inherited;
GraphicClass:=TIcon;
end;
procedure TAppinf.MainDataAfterOpen(DataSet: TDataSet);
var
s:string;
ic:Ticon;
stream:Tstream;
cds:TClientDataSet;
const
Lenv:array[-1..7] of TTreeNode=(nil,nil,nil,nil,nil,nil,nil,nil,nil);
begin
inherited;
dxTreeView1.Items.BeginUpdate;
dxTreeView1.Items.Clear;
cds:=TClientDataSet.Create(self);
try
cds.CloneCursor(maindata,true,true);
cds.First;
while not cds.Eof do
begin
s:=cds.fieldbyname('App_id').AsString;
lenv[length(s) div 2]:=dxTreeView1.Items.AddChildObject(lenv[(length(s) div 2) - 1],cds.fieldbyname('app_nm').AsString,cds.GetBookmark);
Stream:=TMemoryStream.Create;
try
TblobField(cds.fieldbyname('app_ic')).SaveToStream(stream);
if stream.Size>0 then
begin
ic:=Ticon.Create;
try
stream.Seek(soFromBeginning,0);
ic.LoadFromStream(stream);
lenv[length(s) div 2].ImageIndex:=imagelist2.AddIcon(ic);
finally
ic.Free;
end;
end else
lenv[length(s) div 2].ImageIndex:=0;
finally
stream.Free;
end;
lenv[length(s) div 2].Data:=cds.GetBookmark;
cds.Next;
end;
finally
cds.Free;
end;
dxTreeView1.Items.EndUpdate;
end;
procedure TAppinf.MainDataAfterScroll(DataSet: TDataSet);
var
i:integer;
p
ointer;
begin
inherited;
p:=maindata.GetBookmark;
for i:=0 to dxTreeview1.Items.Count-1 do
if maindata.CompareBookmarks(dxTreeview1.items
.data,p)=0 then
begin
dxTreeview1.Selected:=dxTreeview1.items;
exit;
end;
end;
procedure TAppinf.dxTreeView1Change(Sender: TObject
Node: TTreeNode);
begin
inherited;
maindata.GotoBookmark(node.Data);
end;
procedure TAppinf.dxTreeView1Changing(Sender: TObject
Node: TTreeNode;
var AllowChange: Boolean);
begin
inherited;
AllowChange:=not (MainData.State in dsEditModes);
end;
procedure TAppinf.dxDBInspector1APP_STButtonClick(Sender: TObject;
AbsoluteIndex: Integer);
begin
inherited;
with TAppSet.Create(nil,vararrayof([integer(mainsource),'app_ic',maindataapp_id.asstring+' '+maindataapp_nm.asstring,integer(maindataapp_st),maindata.state in dsEditModes])) do
try
showmodal;
finally
free;
end;
end;
procedure TAppinf.dxDBInspector1APP_RGButtonClick(Sender: TObject;
AbsoluteIndex: Integer);
begin
inherited;
with TAppSecurity.Create(nil,vararrayof([integer(mainsource),'app_ic',maindataapp_id.asstring+' '+maindataapp_nm.asstring,integer(maindataapp_rg),maindata.state in dsEditModes])) do
try
showmodal;
finally
free;
end;
end;
procedure TAppinf.dxDBInspector1Row8ButtonClick(Sender: TObject;
AbsoluteIndex: Integer);
begin
inherited;
if MainData.State in dseditmodes then
with TDesignForm.Create(nil,vararrayof([integer(maincon),integer(maindataApp_da)])) do
try
ShowModal;
finally
Free;
end;
end;
procedure TAppinf.MainSourceStateChange(Sender: TObject);
begin
inherited;
dxLayoutControl1Group2.Enabled:=not (MainData.State in dseditmodes);
dxLayoutControl1Group3.Enabled:=not (MainData.State in dseditmodes);
end;
procedure TAppinf.MainDataBeforeEdit(DataSet: TDataSet);
begin
inherited;
MainDataApp_nm.FocusControl;
end;
initialization
RegisterClass(TAppinf);
finalization
UnRegisterClass(TAppinf);
end.
现在我想知道
initialization
RegisterClass(TAppinf);
finalization
UnRegisterClass(TAppinf);
end.
在BCB中到底该怎么实现。谢谢