Hi!! this is my first post in the forum and sorry, if this subforum is not the right place for this message.
I'm trying to make a new control (class) derivated from TEdit class. A easy and simplified code version of this class (the code is for example only) is:
unit NumberEdit;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls, ExtCtrls;
type
tNumero = ( real, entero );
TNumberEdit = class(TEdit)
private
{ Private declarations }
Fmode : tNumero;
TextoPrevio : string;
TeclaTMP : char;
FFontFcsName, FuenteTMP : TFont;
FErrSnd, FErrClr,FFontFcs : BOOLEAN;
PrimeraVezColor, PrimeraVezFuente : BOOLEAN;
FColorErr, ColorTMP : TColor;
FValorEntero : Int64;
FValorReal : extended;
Timer1 : TTimer;
FErrClrTime : cardinal;
protected
{ Protected declarations }
public
{ Public declarations }
published
{ Published declarations }
property ColorErr : TColor read FColorErr write FColorErr;
property Mode : tNumero read FMode write FMode default real;
property ErrClr : BOOLEAN read FErrClr write FErrClr;
property ErrClrTime : cardinal read FErrClrTime write FErrClrTime;
property ErrSnd : BOOLEAN read FErrSnd write FErrSnd;
property FontFcs : BOOLEAN read FFontFcs write FFontFcs;
property FontFcsFont : TFont read FFontFcsName write FFontFcsName;
property ValorEntero : Int64 read FValorEntero write FValorEntero;
property ValorReal : extended read FValorReal write FValorReal;
end;
procedure Register;
implementation
procedure Register;
begin
{$I numberedit_icon.lrs}
RegisterComponents('Standard',[TNumberEdit]);
end;
end. That code compile OK and I can create a new package with this new class: TNumberEdit. Now I can create a new form with this new control, but, I get a problem.
The FontFcsFont is the TFont type. When in the Object inspector I select this one property for setting the initials values, I get the message:
"Cannot assign as Nil to a Tfont"
I think, I should get a font dialogue for setting those values. I was searching information about that problem in different places: they comment that I should create a Property Editors for TFont, But is it necessary?
The ColorErr is another type created by me (TColor type). If I select it in object inspector, then I get the correct dialogue for setting those properties without any extra code
Why yes here, and there, no? What's wrong in my code?
Thank very much in advanced