unit RegEditor_D10;
interface
uses Windows, Forms, Controls, Classes, DesignIntf, DesignEditors, Dialogs,
RegEditor, USubKey;
Type
TKeyProperty = class (TStringProperty)
function GetAttributes : TPropertyAttributes; override;
procedure GetValues(Proc : TGetStrProc); override;
function GetValue : string; override;
procedure SetValue(const Value: string); override;
end;
TSubKeyProperty = class(TPropertyEditor)
function GetAttributes : TPropertyAttributes; override;
function GetValue : string; override;
procedure Edit; override;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterPropertyEditor(TypeInfo(String),TRegEditor,'Key',TKeyProperty);
RegisterPropertyEditor(TypeInfo(String),TRegEditor,'SubKey',TSubKeyProperty);
RegisterComponents('Samples', [TRegEditor]);
end;
function TKeyProperty.GetAttributes : TPropertyAttributes;
begin
Result:=[paValueList];
end;
Procedure TKeyProperty.GetValues(Proc : TGetStrProc);
begin
Proc('HKEY_CLASSES_ROOT');
Proc('HKEY_CURRENT_USER');
Proc('KEY_LOCAL_MACHINE');
Proc('HKEY_USERS');
Proc('HKEY_CURRENT_CONFIG');
end;
function TKeyProperty.GetValue : string;
begin
Result:= GetStrValue;
end;
procedure TKeyProperty.SetValue(const Value: string);
begin
SetStrValue(Value);
designer.Modified;
end;
function TSubKeyProperty.GetAttributes : TPropertyAttributes;
begin
Result:=[paDialog];
end;
function TSubKeyProperty.GetValue : string;
begin
Result:= GetStrValue;
end;
procedure TSubKeyProperty.Edit;
begin
frmSubKey := TfrmSubKey.Create(Application);
try
frmSubKey.Caption := 'Selecciona SubKey';
frmSubKey.ShowModal;
if frmSubKey.ModalResult = mrOK then begin
SetStrValue(frmSubKey.stSubKey.Caption);
designer.Modified;
end;
finally
frmSubKey.Free;
end;
end;
end.