我创建了一个类
FormInfo = class (TComponent)
private
FLeftValue : Integer;
FTopValue : Integer;
FHeightValue : Integer;
FWidthValue : Integer;
public
constructor Create(
AOwner : TComponent;
leftvalue : integer;
topvalue : integer;
heightvalue : integer;
widthvalue : integer);
protected
procedure GetChildren(Proc: TGetChildProc; Root: TComponent); override;
function GetChildOwner: TComponent; override;
//procedure SetParentComponent(Value : TComponent); override;
published
property LeftValue : Integer read FLeftValue write FLeftValue;
property TopValue : Integer read FTopValue write FTopValue;
property HeightValue : Integer read FHeightValue write FHeightValue;
property WidthValue : …Run Code Online (Sandbox Code Playgroud) 如何在事件处理程序中删除所有节点,包括VirtualStringTree后代,关闭包含VirtualStringTree的表单?
有一种数据类型
type
TDataTypeId = (DataTypeId_String, DataTypeId_SmallInt, DataTypeId_Integer, DataTypeId_Word,
DataTypeId_Boolean, DataTypeId_Float, DataTypeId_Currency,
DataTypeId_BCD, DataTypeId_FmtBCD, DataTypeId_Date,
DataTypeId_Time, DataTypeId_DateTime, DataTypeId_TimeStamp,
DataTypeId_Bytes, DataTypeId_VarBytes, DataTypeId_Blob,
DataTypeId_Memo, DataTypeId_Graphic, DataTypeId_fmtMemo,
DataTypeId_FixedChar, DataTypeId_WideChar, DataTypeId_LargeInt,
DataTypeId_Array, DataTypeId_FixedWideChar, DataTypeId_WideMemo);
Run Code Online (Sandbox Code Playgroud)
有一个函数接受包含这种类型的值之一的行,返回该值
Function GetType(str: string): TDataTypeId;
var
typeidx: TDataTypeId;
typestr: string;
begin
for typeidx := Low(TDataTypeID) to High(TDataTypeID) do
begin
typestr:=GetEnumName(TypeInfo(TDataTypeId),Ord(typeidx));
typestr:=Copy(typestr, 12, length(typestr)-11);
//Memo.Lines.Add(typestr+'\n');
if (AnsiCompareStr(str, typestr)=0) then
Result:=typeidx
end;
end;
Run Code Online (Sandbox Code Playgroud)
结果,有一个组件
[dcc32 Warning] UnloadProcs.pas(59): W1035 Return value of function 'GetType' might be undefined
Run Code Online (Sandbox Code Playgroud)
如何转换未出现警告的功能?
有一个代码
for j := 0 to mForm.ComponentCount - 1 do
if mForm.Components[j] is TableFormInfo then
//try
//table := nil;
//tempFmtable := nil;
//tForm := nil;
tForm := mForm.Components[j] as TableFormInfo;
table := TTableSpec(DBSchema.Tables.FindComponent(tForm.Table));
tempFmtable := TfmTableData.Create(MainWindow);
tempFmtable.Name := tForm.Name;
tempFmtable.tname := tForm.Table;
//tempFmtable.Caption := Utf8ToAnsi(table.Description);
tempFmtable.Left := tForm.LeftValue;
tempFmtable.Top := tForm.TopValue;
tempFmtable.Height := tForm.HeightValue;
tempFmtable.Width := tForm.WidthValue;
tempFmTable.IBQuery1.SQL.Clear;
tempFmtable.IBQuery1.SQL.Add('select * from ' + table.Name);
tempFmtable.IBQuery1.Open;
tempFmtable.DragKind:=dkDock;
tempFmtable.DragMode:=dmAutomatic;
i := 0;
querystr:='select ';
while i <= tForm.ComponentCount - 1 do
begin …Run Code Online (Sandbox Code Playgroud) 我通过序列化和对Delphi的表单及其内容的反序列化编写了以下代码
unit SerAndDeser;
interface
uses Classes,MainForm,ListOfTables,DataOfTable,SerialForms,sysutils,ActiveX, DatabaseClasses, UnloadProcs;
procedure Ser();
procedure Deser();
function GetGUID(): string;
function DeleteSymbols(inputstr : string) : string;
implementation
function GetGUID(): string;
var
GUID : TGUID;
begin
Result := '';
if CoCreateGuid(GUID) = 0 then
Result := GUIDToString(GUID);
Result := StringReplace(Result, '{', '', []);
Result := StringReplace(Result, '}', '', []);
Result := StringReplace(Result, '-', '', [rfReplaceAll]);
end;
function DeleteSymbols(inputstr : string): string;
begin
Result := '';
Result := StringReplace(inputstr, '-', '', [rfReplaceAll]);
Result := StringReplace(Result, ' ', …Run Code Online (Sandbox Code Playgroud) sqlite是一个数据库 - 一个描述符,包含表列表,域列表,字段列表,限制列表(主键和外键),索引列表.我在Delphi XE3的帮助下,在内置组件的帮助下连接到此基础.有一个单独的模块,其中描述了类TTableSpec,TFieldSpec,TConstraintSpec,TConstraintDetSpec,TDomainSpec.这些类对应于上述sqlite的基础记录.在TTableSpec类中有这样的FFields字段:TComponent成为像TFieldSpec这样的对象的所有者,它们也是从基础上卸载的(例如,DBSchema也包含FTables字段是所有表的所有者),并且在TFieldSpec类中有FDomainSpec字段:TDomainSpec.实际上我给出了一个连接错误的类代码
type
TDataTypeId = (DataTypeId_String, DataTypeId_SmallInt, DataTypeId_Integer, DataTypeId_Word,
DataTypeId_Boolean, DataTypeId_Float, DataTypeId_Currency,
DataTypeId_BCD, DataTypeId_FmtBCD, DataTypeId_Date,
DataTypeId_Time, DataTypeId_DateTime, DataTypeId_TimeStamp,
DataTypeId_Bytes, DataTypeId_VarBytes, DataTypeId_Blob,
DataTypeId_Memo, DataTypeId_Graphic, DataTypeId_fmtMemo,
DataTypeId_FixedChar, DataTypeId_WideChar, DataTypeId_LargeInt,
DataTypeId_Array, DataTypeId_FixedWideChar, DataTypeId_WideMemo, DataTypeId_Default);
TDBSchemaSpec=class(Tcomponent)
private
FDomains: TComponent;
FTables : TComponent;
public
procedure Setup();
destructor Destroy; override;
property Domains: TComponent read FDomains;
property Tables : TComponent read FTables;
end;
TDomainSpec = class(TComponent)
private
FName: string;
FDescription: String;
FDataTypeId: TDataTypeId;
FLength: Cardinal;
FCharLength: Cardinal;
FPrecision: Cardinal;
FScale: Cardinal;
FWidth: Word;
FAlign: TAlignSpec; …Run Code Online (Sandbox Code Playgroud) delphi ×6
delphi-xe2 ×5
build ×3
warnings ×3
constructor ×1
delphi-xe ×1
function ×1
variables ×1