unit AdoComponent;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
dsgnintf,typinfo,adoconed;
type
TAdoComponent = class(TComponent)
private
{ Private declarations }
FDemo:WideString;
protected
{ Protected declarations }
public
{ Public declarations }
published
{ Published declarations }
property Demo:WideString read FDemo Write FDemo;
end;
TDemoProperty=class(TStringProperty)
function GetAttributes: TPropertyAttributes; override;
procedure Edit;override;
end;
procedure Register;
implementation
function EditConnectionString(Component: TComponent): Boolean;
var
PropInfo: PPropInfo;
NewConnStr,
InitialConnStr: WideString;
begin
Result := False;
with TConnEditForm.Create(Application) do
try
Caption := Format('%s%s%s %s', [Component.Owner.Name, DotSep,
Component.Name, 'demo']);
PropInfo := GetPropInfo(Component.ClassInfo, 'demo');
InitialConnStr := GetStrProp(Component, PropInfo);
NewConnStr := Edit(InitialConnStr);
if NewConnStr <> InitialConnStr then
begin
SetStrProp(Component, PropInfo, NewConnStr);
Result := True;
end;
finally
Free;
end;
end;
procedure Register;
begin
RegisterComponents('CX Lib', [TAdoComponent]);
RegisterPropertyEditor(TypeInfo(WideString), TAdoComponent, 'demo', TDemoProperty);
end;
{ TDemoProperty }
procedure TDemoProperty.Edit;
begin
if EditConnectionString(GetComponent(0) as TComponent) then
Modified;
end;
function TDemoProperty.GetAttributes: TPropertyAttributes;
begin
result:=[padialog];
end;
end.