在对象检查器中产生编辑按钮或下拉菜单(100分)

  • 主题发起人 主题发起人 Johnqiu
  • 开始时间 开始时间
J

Johnqiu

Unregistered / Unconfirmed
GUEST, unregistred user!
我自己设计了一个控件,如何在对象检查器中加入编辑按钮(就是"..."的按钮)或下拉的
按钮??请哪位高手指教
 
给你一个例子,看看,我刚刚写的测试

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,DesignIntf,DesignEditors, StdCtrls;

type
TForm1 = class(TForm)
Memo1: TMemo;
Button1: TButton;
Button2: TButton;
private
{ Private declarations }
public
{ Public declarations }
end;

TComponent1 = class(TComponent)
private
FStringEx: string;
procedure SetStringEx(const Value: string);
{ Private declarations }
protected
{ Protected declarations }
public
{ Public declarations }
published
{ Published declarations }
property StringEx: string read FStringEx write SetStringEx;
end;

TTestProperty = class(TPropertyEditor)
FDataString: string;

procedure Edit; override;
function GetAttributes: TPropertyAttributes; override;
function GetValue: string; override;
end;

function Execute: string;

procedure Register;

implementation
{$R *.dfm}

procedure Register;
begin
RegisterPropertyEditor(TypeInfo(string), TComponent1,'StringEx',TTestProperty);
RegisterComponents('Samples', [TComponent1]);
end;

{ TPDFDataStringProperty }

procedure TTestProperty.Edit;
begin
inherited;
Execute;
end;

function TTestProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paDialog];
end;

function TTestProperty.GetValue: string;
begin

end;


function Execute: string;
begin
with TForm1.Create(Application) do
begin
Position := poDesktopCenter;
ShowModal;
end;
end;

{ TComponent1 }

procedure TComponent1.SetStringEx(const Value: string);
begin
FStringEx := Value;
end;

end.
 
接受答案了.
 

Similar threads

D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
1K
DelphiTeacher的专栏
D
S
回复
0
查看
816
SUNSTONE的Delphi笔记
S
S
回复
0
查看
737
SUNSTONE的Delphi笔记
S
后退
顶部