Hi marcov. Thanks for your answer. I imagined that subject, but there is one thing I don't understand now.
If i change the code, and the new class TTest is child from TEdit, for example,
unit Objetos2;
{$mode objfpc}{$H+}
interface
uses Classes, StdCtrls;
type
TTest = class(TEdit)
private
{ Private declarations }
FXYZ : real;
procedure SetXYZX (const dato : real );
protected
{ Protected declarations }
public
{ Public declarations }
property XYZX : real read FXYZ write SetXYZX;
published
{ Published declarations }
end;
implementation
procedure TTest.SetXYZX (const dato : real );
begin
FXYZ := dato;
end;
end.
The program still crashes, why do I need to reserve memory, yet?
I have a lot of controls made for me, for LCL/IDE - I don't use new/dispose commands - and they work gracefully.
This is part of code of one control (It is a derivative control of TCustomEdit) and the constructor doesn't reserve memory for the new variables:
type
tNumero = ( real, entero );
tBaseNumero = ( Bin, Oct, Dec, Hex );
TOnEffects = procedure (const estado : BOOLEAN) of Object;
TNumberEdit = class(TCustomEdit)
private
{ Private declarations }
Fmode : tNumero;
FNumberBase : tBaseNumero;
FNumberNegative : BOOLEAN;
FColorError : TColor;
FColorErrorTime : cardinal;
ColorTMP : TColor;
Timer1 : TTimer;
FSoundError : BOOLEAN;
FFocusFont : TFont;
FTempFont : TFont;
FValueInteger : Int64;
FValueReal : extended;
FOnError : TNotifyEvent;
FOnChangeNumber : TNotifyEvent;
FOnOverflowNumber : TNotifyEvent;
FOnEffects : TOnEffects;
NumeroPrevioReal : extended;
NumeroPrevioEntero : Int64;
UnDoNumero : string;
UnDoNumero2 : string;
PosicionCursorUnDo : integer;
PosicionCursorUnDo2 : integer;
ActivadoUnDo : BOOLEAN;
ActivadoEfecto : BOOLEAN;
procedure CambiaColor (Sender : TObject);
procedure RestauraColor (Sender : TObject);
procedure CadenaAReal;
procedure CadenaAEntero;
procedure SetFocusFont(AValue: TFont);
procedure GuardaValorParaUnDo;
protected
........
constructor TNumberEdit.Create(AOwner : TComponent);
begin
inherited Create (AOwner);
FMode := real;
FNumberBase := Dec;
FNumberNegative := TRUE;
FColorError := clDefault;
Timer1 := TTimer.Create (Self);
Timer1.OnStartTimer := @CambiaColor;
Timer1.OnTimer := @RestauraColor;
Timer1.Enabled := FALSE;
FFocusFont := TFont.Create;
FFocusFont.Assign(Self.Font);
FFocusFont.Name := 'Comic Sans MS';
FFocusFont.Size := 14;
FTempFont := TFont.Create;
ActivadoEfecto := FALSE;
ActivadoUnDo := FALSE;
end;
Where was made the memory resever for the new variables?: FMode, ActivadoEfecto , FNumberBase ...
¿LCL made the reserve of memory?
Thanks again