[DELPHI]unit MultiDisplay;
interface
uses
SysUtils, Classes, Controls, ExtCtrls, Graphics,UDiGDisplayJL2;
type
TDisplay1 =class(TPersistent) //Para crear propiedades agrupadas 2/
private
FDigits: byte; { Número de digitos a representar }
FValue: string; { Valor a arepresentar }
FBckgndColor, FDigitOnColor, FDigitOffColor: TColor; { Colores }
FAlignment: TAlignment; { Alineación horizontal }
FLeadingZeros: boolean; { Rellenar con ceros }
FTipoVisor : TTypeVisor;
procedure setTipoVisor(const Value:TTypeVisor);
procedure SetDigits(Value: byte);
procedure SetValue(Value: String);
procedure SetBckgndColor(Value: TColor);
procedure SetDigitOnColor(Value: TColor);
procedure SetDigitOffColor(Value: TColor);
procedure SetAlignment(Value: TAlignment);
procedure SetLeadingZeros(Value: boolean);
published
property LeadingZeros : boolean read FLeadingZeros write SetLeadingZeros default False;
property Alignment : TAlignment read FAlignment write SetAlignment default taRightjustify;
property Digits : byte read FDigits write SetDigits default 4;
property Value : string read FValue write SetValue;
property BckgndColor : TColor read FBckgndColor write SetBckgndColor;
property DigitOnColor : TColor read FDigitOnColor write SetDigitOnColor;
property DigitOffColor : TColor read FDigitOffColor write SetDigitOffColor;
property TipoVisor : TTypeVisor read FTipoVisor write SetTipoVisor default VNumeric;
end;
type
TDisplay2 =class(TPersistent) //Para crear propiedades agrupadas 2/
private
FDigits: byte; { Número de digitos a representar }
FValue: string; { Valor a arepresentar }
FBckgndColor, FDigitOnColor, FDigitOffColor: TColor; { Colores }
FAlignment: TAlignment; { Alineación horizontal }
FLeadingZeros: boolean; { Rellenar con ceros }
FTipoVisor : TTypeVisor;
procedure setTipoVisor(const Value:TTypeVisor);
procedure SetDigits(Value: byte);
procedure SetValue(Value: String);
procedure SetBckgndColor(Value: TColor);
procedure SetDigitOnColor(Value: TColor);
procedure SetDigitOffColor(Value: TColor);
procedure SetAlignment(Value: TAlignment);
procedure SetLeadingZeros(Value: boolean);
published
property LeadingZeros : boolean read FLeadingZeros write SetLeadingZeros default False;
property Alignment : TAlignment read FAlignment write SetAlignment default taRightjustify;
property Digits : byte read FDigits write SetDigits default 4;
property Value : string read FValue write SetValue;
property BckgndColor : TColor read FBckgndColor write SetBckgndColor;
property DigitOnColor : TColor read FDigitOnColor write SetDigitOnColor;
property DigitOffColor : TColor read FDigitOffColor write SetDigitOffColor;
property TipoVisor : TTypeVisor read FTipoVisor write SetTipoVisor default VNumeric;
end;
type
TDisplay3 =class(TPersistent) //Para crear propiedades agrupadas 2/
private
FDigits: byte; { Número de digitos a representar }
FValue: string; { Valor a arepresentar }
FBckgndColor, FDigitOnColor, FDigitOffColor: TColor; { Colores }
FAlignment: TAlignment; { Alineación horizontal }
FLeadingZeros: boolean; { Rellenar con ceros }
FTipoVisor : TTypeVisor;
procedure setTipoVisor(const Value:TTypeVisor);
procedure SetDigits(Value: byte);
procedure SetValue(Value: String);
procedure SetBckgndColor(Value: TColor);
procedure SetDigitOnColor(Value: TColor);
procedure SetDigitOffColor(Value: TColor);
procedure SetAlignment(Value: TAlignment);
procedure SetLeadingZeros(Value: boolean);
published
property LeadingZeros : boolean read FLeadingZeros write SetLeadingZeros default False;
property Alignment : TAlignment read FAlignment write SetAlignment default taRightjustify;
property Digits : byte read FDigits write SetDigits default 4;
property Value : string read FValue write SetValue;
property BckgndColor : TColor read FBckgndColor write SetBckgndColor;
property DigitOnColor : TColor read FDigitOnColor write SetDigitOnColor;
property DigitOffColor : TColor read FDigitOffColor write SetDigitOffColor;
property TipoVisor : TTypeVisor read FTipoVisor write SetTipoVisor default VNumeric;
end;
type
TComunes =class(TPersistent) //Para crear propiedades agrupadas 2/
private
FComun: Boolean; //Usa en los displays las mismas caracteristicas
FDigits: byte; { Número de digitos a representar }
FBckgndColor, FDigitOnColor, FDigitOffColor: TColor; { Colores }
FAlignment: TAlignment; { Alineación horizontal }
FLeadingZeros: boolean; { Rellenar con ceros }
FTipoVisor : TTypeVisor;
procedure SetComun(value:Boolean);
procedure setTipoVisor(const Value:TTypeVisor);
procedure SetDigits(Value: byte);
procedure SetBckgndColor(Value: TColor);
procedure SetDigitOnColor(Value: TColor);
procedure SetDigitOffColor(Value: TColor);
procedure SetAlignment(Value: TAlignment);
procedure SetLeadingZeros(Value: boolean);
published
property Comun : Boolean read FComun write SetComun default False;
property LeadingZeros : boolean read FLeadingZeros write SetLeadingZeros default False;
property Alignment : TAlignment read FAlignment write SetAlignment default taRightjustify;
property Digits : byte read FDigits write SetDigits default 4;
property BckgndColor : TColor read FBckgndColor write SetBckgndColor;
property DigitOnColor : TColor read FDigitOnColor write SetDigitOnColor;
property DigitOffColor : TColor read FDigitOffColor write SetDigitOffColor;
property TipoVisor : TTypeVisor read FTipoVisor write SetTipoVisor default VNumeric;
end;
type
TEspacio = 0..5;
TNumbers = 1..3;
TMultiDisplay = class(TPanel)
private
{ Private declarations }
FDisplay1 :TDisplay1;
FDisplay2 :TDisplay2;
FDisplay3 :TDisplay3;
FComunes :TComunes;
FSpace :TEspacio;
FNumbersDisplays :TNumbers;
FDisp1 :TDigitDisplayJL_R; //HAy que tener instalado la unidad UdigiDiplsy
FDisp2 :TDigitDisplayJL_R;
FDisp3 :TDigitDisplayJL_R;
procedure SetSpace(Value:TEspacio);
procedure SetNumbersDisplays(Value:TNumbers);
protected
{ Protected declarations }
procedure Paint; override;
procedure Resize; override;
public
{ Public declarations }
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure clear;
published
property Space :TEspacio read FSpace Write SetSpace;
property NumbersDisplays :TNumbers read FNumbersDisplays write SetNumbersDisplays;
property Display1 :TDisplay1 read FDisplay1 write FDisplay1;
property Display2 :TDisplay2 read FDisplay2 write FDisplay2;
property Display3 :TDisplay3 read FDisplay3 write FDisplay3;
property Comunes :TComunes read FComunes write FComunes;
{ Published declarations }
end;[/DELPHI]
hasta aquí todo bien, el problema surge cuando quiero acceder a un cambio desde por Ejemplo Tdisplay1.value a Disp1.value, investigando en internet he visto en otros componetes que declaran la clase del componente antes de su uso (de que realmente se cree) de la siguiente forma, seria por ejemplo en el TDisplay1
[DELPHI]TMultiDisplay = class;[/DELPHI]
y luego dentro de mi Tdiplay1 iría las siguientes lineas de código
[DELPHI]uses
SysUtils, Classes, Controls, ExtCtrls, Graphics,UDiGDisplayJL2;
TMultiDisplay = class;
type
TDisplay1 =class(TPersistent) //Para crear propiedades agrupadas 2/
private
FDigits: byte; { Número de digitos a representar }
FMulti :TMultiDisplay;
FValue: string; { Valor a arepresentar }
FBckgndColor, FDigitOnColor, FDigitOffColor: TColor; { Colores }
FAlignment: TAlignment; { Alineación horizontal }
FLeadingZeros: boolean; { Rellenar con ceros }
FTipoVisor : TTypeVisor;
procedure setTipoVisor(const Value:TTypeVisor);
procedure SetDigits(Value: byte);
procedure SetValue(Value: String);
procedure SetBckgndColor(Value: TColor);
procedure SetDigitOnColor(Value: TColor);
procedure SetDigitOffColor(Value: TColor);
procedure SetAlignment(Value: TAlignment);
procedure SetLeadingZeros(Value: boolean);
procedure SetMulti(value:TMultiDisplay);
published
property LeadingZeros : boolean read FLeadingZeros write SetLeadingZeros default False;
property Alignment : TAlignment read FAlignment write SetAlignment default taRightjustify;
property Digits : byte read FDigits write SetDigits default 4;
property Value : string read FValue write SetValue;
property BckgndColor : TColor read FBckgndColor write SetBckgndColor;
property DigitOnColor : TColor read FDigitOnColor write SetDigitOnColor;
property DigitOffColor : TColor read FDigitOffColor write SetDigitOffColor;
property TipoVisor : TTypeVisor read FTipoVisor write SetTipoVisor default VNumeric;
property Multi: TMultiDisplay read FMulti write SetMulti;
end;
[/DELPHI]
Pero me da los siguientes errores
[DCC Error] MultiDisplay.pas(10): E2086 Type 'TMultiDisplay' is not yet completely defined
[DCC Error] MultiDisplay.pas(131): E2004 Identifier redeclared: 'TMultiDisplay'
[DCC Error] MultiDisplay.pas(28): E2005 'TMultiDisplay' is not a type identifier
Si me podéis explicar que estoy haciendo mal y cual sería la forma correcta, me ayudaríais mucho.
Como siempre gracias