Cara .. sempre fiz isso, mas com minha classe herdada de TPersistent e
sempre funcionou numa boa.. ..
Teoricamente não teria pq não funcionar, pois TGraphicsObject descende
diretamente de TPersistent.
O pior é que não vejo nada no seu código que possa causar este problema.

Gera exception? Qual?

2008/10/13 Willian Jhonnes L. dos Santos <[EMAIL PROTECTED]>:
> Olá, boa tarde a todos...
>
> Criei alguns componentes para suprir algumas necessidades de
> desenvolvimento na empresa para a qual trabalho, os quais têm a
> característica de colorizar o componente (TEdit, TMaskEdit, TComboBox,
> etc.) conforme foco e preenchimento. Para agrupar as propriedades das
> cores em um lugar único, criei uma classe para elas [1]. Em um
> componente descendente do TMaskEdit, a classe é instanciada sem problema
> [2], mas em um componente descendente do TEdit, ela não é instanciada,
> mesmo com a indicação em seu construtor [3].
>
> Alguém tem alguma idéia de qual seja o problema?
>
> []'s
>
> [1] - { TColors }
>  TColors = class(TGraphicsObject)
>    private
>      { Private declarations }
>      FFocusColor,
>      FRightColor,
>      FWrongColor: TColor;
>      FNotify: IChangeNotifier;
>    protected
>      { Protected declarations }
>      procedure Changed; override;
>      procedure SetFocusColor(Value: TColor);
>      procedure SetRightColor(Value: TColor);
>      procedure SetWrongColor(Value: TColor);
>    public
>      { Public declarations }
>      constructor Create;
>      destructor  Destroy; override;
>      procedure Assign(Source: TPersistent); override;
>    published
>      { Published declarations }
>      property FocusColor: TColor read FFocusColor write SetFocusColor;
>      property RightColor: TColor read FRightColor write SetRightColor;
>      property WrongColor: TColor read FWrongColor write SetWrongColor;
>  end;
>
> { TColors }
>
> procedure TColors.Assign(Source: TPersistent);
> begin
>  if Source is TColors then
>  begin
>    Lock;
>    try
>      TColors(Source).Lock;
>      try
>        FFocusColor := TColors(Source).FocusColor;
>        FRightColor := TColors(Source).RightColor;
>        FWrongColor := TColors(Source).WrongColor;
>      finally
>        TColors(Source).Unlock;
>      end;
>    finally
>      Unlock;
>    end;
>    Exit;
>  end;
>  inherited Assign(Source);
> end;
>
> procedure TColors.Changed;
> begin
>  inherited Changed;
>  if FNotify <> nil then
>    FNotify.Changed;
> end;
>
> constructor TColors.Create;
> begin
>  FFocusColor := $00FFEFDF;
>  FRightColor := $00DFFFEF;
>  FWrongColor := $00EFDFFF;
> end;
>
> destructor TColors.Destroy;
> begin
>  FreeInstance;
> end;
>
> procedure TColors.SetFocusColor(Value: TColor);
> begin
>  if FFocusColor <> Value then
>  begin
>    FFocusColor := Value;
>    Changed;
>  end;
> end;
>
> procedure TColors.SetRightColor(Value: TColor);
> begin
>  if FRightColor <> Value then
>  begin
>    FRightColor := Value;
>    Changed;
>  end;
> end;
>
> procedure TColors.SetWrongColor(Value: TColor);
> begin
>  if FWrongColor <> Value then
>  begin
>    FWrongColor := Value;
>    Changed;
>  end;
> end;
>
> -----------------------------------------------------
>
> [2] - { TTutorialMaskEdit }
>  TTutorialMaskEdit = class(TMaskEdit)
>    private
>      { Private declarations }
>      FMandatory,
>      FRequired,
>      FColorize,
>      FValidate,
>      FSaveLiterals,
>      FShowMessages: Boolean;
>      FColors: TColors;
>      FMaskType: TMaskType;
>      FAlternate: TAlternableMask;
>      FCharForBlanks: Char;
>      FOriginalColor: TColor;
>      FControlMask: Byte;
>      FMsgs: TMaskEditMessages;
>      FAlternableShortCut: TShortCut;
>      FMsgType: TMessageType;
>      procedure SetMask(Mask: TMaskType);
>      procedure SetColors(Value: TColors);
>      procedure SetColorize(Value: Boolean);
>      procedure SetRequired(Value: Boolean);
>      procedure SetValidate(Value: Boolean);
>      procedure SetMessages(Value: TMaskEditMessages);
>    protected
>      { Protected declarations }
>      procedure DoEnter; override;
>      procedure DoExit; override;
>      procedure KeyUp(var Key: Word; Shift: TShiftState); override;
>    public
>      { Public declarations }
>    published
>      { Published declarations }
>      constructor Create(AOwner: TComponent); override;
>      property Mandatory: Boolean read FMandatory write FMandatory
> default False;
>      property Colorize: Boolean read FColorize write SetColorize
> default True;
>      property Required: Boolean read FRequired write SetRequired
> default True;
>      property Validate: Boolean read FValidate write SetValidate
> default True;
>      property SaveLiterals: Boolean read FSaveLiterals write
> FSaveLiterals default False;
>      property MaskType: TMaskType read FMaskType write SetMask;
>      property Colors: TColors read FColors write SetColors;
>      property AlternableMasks: TAlternableMask read FAlternate write
> FAlternate;
>      property CharForBlanks: Char read FCharForBlanks write FCharForBlanks;
>      property AlternableShortCut: TShortCut read FAlternableShortCut
> write FAlternableShortCut;
>      property ShowMessages: Boolean read FShowMessages write FShowMessages;
>      property Messages: TMaskEditMessages read FMsgs write SetMessages;
>      property MessageType: TMessageType read FMsgType write FMsgType;
>  end;
>
> ..
> ..
> ..
>
> constructor TTutorialMaskEdit.Create(AOwner: TComponent);
> begin
>  inherited Create(AOwner);
>  SetMask(mtCustom);
>  FMandatory := False;
>  FRequired := True;
>  FColorize := True;
>  FColors := TColors.Create;
>  FMsgs := TMaskEditMessages.Create;
>  FCharForBlanks := #32;
>  FSaveLiterals := False;
>  FControlMask := 0;
> end;
>
> -----------------------------------------------------
>
> [3] - { TTutorialDateEdit }
>  TTutorialDateEdit = class(TEdit)
>    private
>      { Private declarations }
>      FMinDate,
>      FMaxDate: TDate;
>      FMandatoryState,
>      FMandatory,
>      FShowMessages,
>      FColorize,
>      FRequired    : Boolean;
>      FMask: String;
>      FMsgs: TDateEditMessages;
>      FMsgType: TMessageType;
>      FColors: TColors;
>      function  GetDate: TDate;
>      procedure SetDate(D: TDate);
>      procedure SetMessages(Value: TDateEditMessages);
>      procedure SetColors(Value: TColors);
>      procedure SetColorize(Value: Boolean);
>      procedure SetRequired(Value: Boolean);
>    protected
>      { Protected declarations }
>      procedure KeyPress(var Key: Char); override;
>      procedure KeyUp(var Key: Word; Shift: TShiftState); override;
>      procedure DoEnter; override;
>      procedure DoExit; override;
>      procedure Change; override;
>    public
>      { Public declarations }
>    published
>      { Published declarations }
>      constructor Create(AOwner: TComponent);
>      property DateValue: TDate read GetDate write SetDate;
>      property MinDate: TDate read FMinDate write FMinDate;
>      property MaxDate: TDate read FMaxDate write FMaxDate;
>      property Mandatory: Boolean read FMandatory write FMandatory;
>      property ShowMessages: Boolean read FShowMessages write FShowMessages;
>      property Colorize: Boolean read FColorize write SetColorize;
>      property Required: Boolean read FRequired write SetRequired;
>      property Mask: String read FMask;
>      property Messages: TDateEditMessages read FMsgs write SetMessages;
>      property MessageType: TMessageType read FMsgType write FMsgType;
>      property Colors: TColors read FColors write SetColors;
>  end;
>
> ..
> ..
> ..
>
> constructor TTutorialDateEdit.Create(AOwner: TComponent);
> begin
>  inherited Create(AOwner);
>  FRequired := True;
>  FColorize := True;
>  FColors := TColors.Create;
>  FMsgs := TDateEditMessages.Create;
>  FMask := 'DD/MM/YYYY';
>  SetDate(Date);
>  FMsgType := mtAlert;
> end;
>
> --
> ---------------------------------------------------
> Att.:
> Willian Jhonnes L. dos Santos
> Analista/Desenvolvedor Object/Free Pascal
> [EMAIL PROTECTED]
> ---------------------------------------------------
> Seja livre. Use Linux.
> Grupo de Usuários GNU/Linux de São José dos Pinhais
> Linux user number 449753
> ---------------------------------------------------
> Powered by Slackware Linux 12.0
> Kernel 2.6.21.5-custom
> ---------------------------------------------------
>
>
> ------------------------------------
>
> --
> <<<<< FAVOR REMOVER ESTA PARTE AO RESPONDER ESTA MENSAGEM >>>>>
>
>
>
>



-- 
Abs
Daniel A. Bastos

Responder a