Registriert seit: 9. Jun 2005
Ort: Unna
1.172 Beiträge
Delphi 10.2 Tokyo Professional
|
Re: Edit mit Disable-Farbe: Farbprobleme mit XP-Manifest
1. Nov 2005, 12:20
Damit du möglichst wenig ändern musst hab' ich den Komponentennamen mal beibehalten.
Delphi-Quellcode:
PBExEdit;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls,
Forms, Dialogs, StdCtrls;
type
TPBExEdit = class(TEdit)
private
{ Private declarations }
FDisabledColor: TColor;
FDisabledTextColor: TColor;
FNormalColor: TColor;
FNormalTextColor: TColor;
procedure CMEnabledChanged(var msg: TMessage); message CM_ENABLEDCHANGED;
procedure SetDisabledColor(const Value: TColor); virtual;
procedure SetDisabledTextColor(const Value: TColor); virtual;
protected
{ Protected declarations }
public
{ Public declarations }
constructor Create(aOwner: TComponent); override;
published
{ Published declarations }
property DisabledTextColor: TColor read FDisabledTextColor
write SetDisabledTextColor default clGrayText;
property DisabledColor: TColor read FDisabledColor
write SetDisabledColor default clWindow;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('PBGoodies', [TPBExEdit]);
end;
constructor TPBExEdit.Create(aOwner: TComponent);
begin
inherited;
FNormalColor := clWindow;
FNormalTextColor := clWindowText;
FDisabledColor := clWindow;
FDisabledTextColor := clGrayText;
end;
procedure TPBExEdit.SetDisabledColor(const Value: TColor);
begin
if FDisabledColor <> Value then
begin
FDisabledColor := Value;
if not Enabled then
Color := Value;
end;
end;
procedure TPBExEdit.SetDisabledTextColor(const Value: TColor);
begin
if FDisabledTextColor <> Value then
begin
FDisabledTextColor := Value;
if not Enabled then
Font.Color := Value;
end;
end;
procedure TPBExEdit.CMEnabledChanged(var msg: TMessage);
begin
if Enabled then
begin
Font.Color := FNormalTextColor;
Color := FNormalColor;
end
else
begin
FNormalTextColor := Font.Color;
FNormalColor := Color;
Font.Color := FDisabledTextColor;
Color := FDisabledColor;
end;
inherited;
end;
end.
|
|
Zitat
|