假设:TMyEdit = class(TEdit)
private
publish
property Color: TColor read FColor write setColor default clRed;........做成一个组件,放到组件面板上,我要做到,拉一个TMyEdit放到窗体上,TMyEdit的颜色变成红色。注意:是设计时改,不是运行后,property Color这边的Color不能改成其他的。
private
publish
property Color: TColor read FColor write setColor default clRed;........做成一个组件,放到组件面板上,我要做到,拉一个TMyEdit放到窗体上,TMyEdit的颜色变成红色。注意:是设计时改,不是运行后,property Color这边的Color不能改成其他的。
unit MyEdit;interfaceuses
Windows, Messages, SysUtils, Classes, Controls, StdCtrls,Graphics;type
TMyEdit = class(TEdit)
private
// FColor: TColor;
{ Private declarations }
protected
{ Protected declarations }
public
{ Public declarations }
constructor Create(AOwner: TComponent); override;
// procedure setcolor(Value:TColor);override;
// function IsColorStored: Boolean;
published
{ Published declarations }
// property Color: TColor read FColor write SetColor stored IsColorStored default clred;
end;procedure Register;implementationprocedure Register;
begin
RegisterComponents('Standard', [TMyEdit]);
end;{ TMyEdit }constructor TMyEdit.Create(AOwner: TComponent);//重新构造一下即可
begin
inherited;
Color := clRed ;
end;end.
大概意思就是怎么自己设置TEdit的颜色,大概需要重新画!!!
unit MyEdit;interfaceuses
Windows, Messages, SysUtils, Classes, Controls, StdCtrls,Graphics;type
TMyEdit = class(TCustomEdit)
private
{ Private declarations }
property Color;
protected
{ Protected declarations } public
{ Public declarations }
constructor Create(AOwner: TComponent); override;
published
{ Published declarations }
property Anchors;
property AutoSelect;
property AutoSize;
property BevelEdges;
property BevelInner;
property BevelKind default bkNone;
property BevelOuter;
property BiDiMode;
property BorderStyle;
property CharCase;
property Constraints;
property Ctl3D;
property DragCursor;
property DragKind;
property DragMode;
property Enabled;
property Font;
property HideSelection;
property ImeMode;
property ImeName;
property MaxLength;
property OEMConvert;
property ParentBiDiMode;
property ParentColor;
property ParentCtl3D;
property ParentFont;
property ParentShowHint;
property PasswordChar;
property PopupMenu;
property ReadOnly;
property ShowHint;
property TabOrder;
property TabStop;
property Text;
property Visible;
property OnChange;
property OnClick;
property OnContextPopup;
property OnDblClick;
property OnDragDrop;
property OnDragOver;
property OnEndDock;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
property OnStartDock;
property OnStartDrag;
end;procedure Register;implementationprocedure Register;
begin
RegisterComponents('Standard', [TMyEdit]);
end;{ TMyEdit }constructor TMyEdit.Create(AOwner: TComponent);
begin
inherited;
Color := clRed ;
end;end.
很想和你交个朋友,向你请教问题!我的QQ75442606