可以实现,但必须在运行时创建对象:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
procedure FormShow(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
type TStaticEdit=class(TEdit)
protected
procedure CreateParams(var Params: TCreateParams); override;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TStaticEdit.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
CreateSubClass(Params, 'STATIC');
end;
procedure TForm1.FormShow(Sender: TObject);
begin
with TStaticEdit.Create(self) do begin
Parent:=self;
left:=0;
top:=0;
width:=400;
Text:='This EDIT control can not be focused!';
end;
end;
end.