Weil mich die Sache interessiert hat, hab ich mal ein bisschen rumprobiert. Hier das Ergebnis:
Delphi-Quellcode:
unit EditEx;
interface
uses
Windows, Messages, SysUtils, Classes, Controls, StdCtrls, Graphics;
type
TEditEx =
class(TEdit)
private
FColor: TColor;
FCursor: TCursor;
FOnlyShow: Boolean;
function GetColor: TColor;
function GetCursor: TCursor;
function IsColorStored: Boolean;
function IsCursorStored: Boolean;
procedure SetColor(
const Value: TColor);
procedure SetCursor(
const Value: TCursor);
procedure SetOnlyShow(
const Value: Boolean);
published
property Color: TColor
read GetColor
write SetColor
stored IsColorStored
default clWindow;
property Cursor: TCursor
read GetCursor
write SetCursor
stored IsCursorStored
default crDefault;
property OnlyShow: Boolean
read FOnlyShow
write SetOnlyShow;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('
Beispiele', [TEditEx]);
end;
{ TEditEx }
function TEditEx.GetColor: TColor;
begin
Result :=
inherited Color;
end;
function TEditEx.GetCursor: TCursor;
begin
Result :=
inherited Cursor;
end;
function TEditEx.IsColorStored: Boolean;
begin
Result :=
not ParentColor
and not OnlyShow;
end;
function TEditEx.IsCursorStored: Boolean;
begin
Result :=
not OnlyShow;
end;
procedure TEditEx.SetColor(
const Value: TColor);
begin
if not OnlyShow
then
inherited Color := Value;
end;
procedure TEditEx.SetCursor(
const Value: TCursor);
begin
if not OnlyShow
then
inherited Cursor := Value;
end;
procedure TEditEx.SetOnlyShow(
const Value: Boolean);
begin
if FOnlyShow <> Value
then
begin
FOnlyShow := Value;
if OnlyShow
then
begin
FColor :=
inherited Color;
FCursor :=
inherited Cursor;
inherited Color := clBtnFace;
inherited Cursor := crArrow;
end
else
begin
inherited Color := FColor;
inherited Cursor := FCursor;
end;
end;
end;
end.