inifiledeg.pas
来自「读写INIFILE文件,Delphi源代码」· PAS 代码 · 共 68 行
PAS
68 行
unit inifiledeg;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls,
Forms, Dialogs, DsgnIntf,IniFiles;
type
Tinifiledeg = class(TComponent)
private
{ Private declarations }
Finifilename:string;
protected
{ Protected declarations }
public
procedure execute;
{ Public declarations }
published
{ Published declarations }
property inifilename:string read Finifilename write Finifilename;
end;
TiniFileProperty = class(TStringProperty)
public
procedure Edit; override;
function GetAttributes: TPropertyAttributes; override;
end;
procedure Register;
implementation
procedure execute;
var
Finifilename:string;
begin
end;
procedure Register;
begin
RegisterComponents('Mohan', [Tinifiledeg]);
RegisterPropertyEditor(TypeInfo(string), Tinifiledeg, 'iniFILEName', TiniFileProperty);
end;
procedure TiniFileProperty.Edit;
var
MPFileOpen: TOpenDialog;
begin
MPFileOpen:= TOpenDialog.Create(Application);
MPFileOpen.fileName:= GetValue;
MPFileOpen.filter:= 'inifiles(*.ini)|*.ini';
MPFileOpen.helpContext:= 0;
MPFileOpen.options:= MPFileOpen.Options + [ofPathMustExist, ofFileMustExist];
Try
If MPFileOpen.Execute Then
begin
SetValue(MPFileOpen.fileName);
end;
Finally
MPFileOpen.Free;
end;
end;
function TiniFileProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paDialog, paRevertable];
end;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?