Recent

Author Topic: component fshcomp  (Read 14095 times)

selimr

  • Guest
component fshcomp
« on: January 22, 2006, 04:42:50 pm »

dan

  • New Member
  • *
  • Posts: 11
RE: component fshcomp
« Reply #1 on: January 23, 2006, 09:12:52 pm »
Very nice components. But SrEditInt includes "strtoint" bug. Cannot convert formated string "1 234" to integer, because formated string includes space character. And this component is not multiplatform :-(

dan

  • New Member
  • *
  • Posts: 11
RE: component fshcomp
« Reply #2 on: January 23, 2006, 10:11:25 pm »
patched SrEditInt.pas:

///**************************************************************************///
///************                                                  ************///
///************   SrEditInt ver : 2.00        selim reis         ************///
///************                                                  ************///
///************   lazarus components                             ************///
///************                                                  ************///
///************   reis_selim@hotmail.com      10/11/2005         ************///
///************                                                  ************///
///**************************************************************************///

unit SrEditInt;

{$mode objfpc}{$H+}

interface

///**************************************************************************///
uses
  Classes, SysUtils, LResources, Forms, Controls, windows,
  Graphics, Dialogs, StdCtrls, lmessages;
///**************************************************************************///

type

{ TSrEditInt }

  TSrEditInt = class(TEdit)

///**************************************************************************///
 private
   FColorActive       : TColor;
   FColorActiveText   : TColor;
   TColorActive       : Tcolor;
   TColorActiveText   : Tcolor;
   Frm                : string;
   FvalueInteger      : integer;
   aktif              : integer;
   procedure gunvalueInteger(const Value: integer);
   procedure rightlean(var xe: TEdit);
///**************************************************************************///
protected
   procedure DoEnter; Override;
   procedure DoExit ; Override;
   procedure KeyPress (var Key: Char); Override;
   procedure WMPaint  (var Message: TLMPaint); message LM_PAINT;
///**************************************************************************///
public
   Constructor Create (AOwner : TComponent); Override;
///**************************************************************************///
published
   property Autosize;
   property BorderStyle;
   property Ctl3D;
   property Cursor;
   property DragCursor;
   property DragKind;
   property DragMode;
   property Enabled;
   property Font;
   property maxlength;
   property Name;
   property ParentColor;
   property parentCtl3D;
   property ParentFont;
   property ParentShowhint;
   property PopupMenu;
   property ReadOnly;
   property ShowHint;
   property TabOrder;
   property Text;
   property Visible;
   property OnChange;
   property OnClick;
   property OnDblClick;
   property OnDragDrop;
   property OnDragOver;
   property OnEndDrag;
   property OnEnter;
   property OnExit;
   property OnKeyDown;
   property OnKeyPress;
   property OnKeyUp;
   property OnMouseDown;
   property OnMouseMove;
   property OnMouseUp;
   property ValueInteger   :integer read FvalueInteger    write gunvalueInteger;
   property ColorActive    :TColor  read FColorActive     write FColorActive;
   property ColorActiveText:TColor  read FColorActiveText write FColorActiveText;
end;
///**************************************************************************///

procedure Register;

implementation

///**************************************************************************///

{ TSrEditInt }

///**************************************************************************///
procedure Register;
begin
   RegisterComponents('fsh', [TSrEditInt]);
end;
///**************************************************************************///
constructor TSrEditInt.Create(AOwner: TComponent);
  begin
    inherited Create (AOwner);
    frm              := ',0';
    FColorActive     := ClWhite;
    FColorActiveText := ClRed;
    ParentCtl3D      := False;
    Ctl3D            := False;
    Height           := 19;
    Color            := ClInfoBk;
    Font.Color       := ClBlue;
    width            := 120;
    Text             := '0';
    ValueInteger     := 0;
    aktif            := 1;
end;
///**************************************************************************///
procedure TSrEditInt.DoEnter;
  begin
    inherited;
    aktif            := 0;
    TColorActive     := color;
    TColorActiveText := font.Color;
    color            := fcoloractive;
    font.color       := fcoloractivetext;
  end;
///**************************************************************************///
procedure TSrEditInt.DoExit;
var
 edt: string;
 dummy: integer;
  begin
    inherited;
    color        := TColorActive;
    font.color   := TColorActiveText;
    if text='' then edt:='0' else edt:= text;
    while pos(ThousandSeparator,edt)<>0 do delete(edt,pos(ThousandSeparator,edt),1);
    edt:= StringReplace (edt, ThousandSeparator,  '', [rfReplaceAll]);
    if TryStrToInt(edt, dummy) then
    begin
      text         := formatfloat(frm,strtoint(edt));
      valueInteger := strtoint(edt);
    end else
    begin
      text         := formatfloat(frm, 0);
      valueInteger := 0;
    end;
    aktif        := 1;
  end;
///**************************************************************************///
procedure TSrEditInt.gunvalueInteger(const Value: integer);
begin
  if fvalueInteger = Value then exit;
  FvalueInteger   := Value;
  text            := formatfloat(frm,valueinteger);
end;
///**************************************************************************///
procedure TSrEditInt.KeyPress(var Key: Char);
  var
   tus: char;
   edt: string;
   yer,nk1,nk2,i : integer;
   dummy: integer;
   
begin
   inherited;
   tus := key;
   key := #0;
   yer := selstart;

   case tus of {case baþla}
     #13 :
     begin
       PostMessage(Handle,WM_KEYDOWN,39,0);
       PostMessage(Handle,WM_KEYDOWN,09,0);
     end;
     '0'..'9' :
     begin
       if sellength=length(text) then text:='';
       nk1:=0;
       for i:=1 to length(Text) do if copy(Text,i,1)=ThousandSeparator then nk1:=nk1+1;
       edt:=copy(text,1,yer)+tus+copy(text,yer+1,length(text));
       while pos(ThousandSeparator,edt)<>0 do delete(edt,pos(ThousandSeparator,edt),1);
       edt:= StringReplace (edt, ThousandSeparator,  '', [rfReplaceAll]);
       if TryStrToInt(edt, dummy) then
       begin
         text:= formatfloat(frm, StrToInt(edt));
         nk2:=0;
         for i:=1 to length(Text) do if copy(Text,i,1)=ThousandSeparator then nk2:=nk2+1;
         if nk2>nk1 then yer:=yer+2 else yer:=yer+1;
         selstart:=yer;
       end else
       begin
         Key:= #0;
       end;
     end;
     #8 :
     begin
       nk1:=0;
       for i:=1 to length(Text) do if copy(Text,i,1)=ThousandSeparator then nk1:=nk1+1;
       edt:=copy(text,1,yer-1)+copy(text,yer+1,length(text));
       while pos(ThousandSeparator,edt)<>0 do delete(edt,pos(ThousandSeparator,edt),1);
       if edt='' then edt:='0';
       edt:= StringReplace (edt, ThousandSeparator,  '', [rfReplaceAll]);
       text:=formatfloat(frm,strtofloat(edt));
       nk2:=0;
       for i:=1 to length(Text) do if copy(Text,i,1)=ThousandSeparator then nk2:=nk2+1;
       if nk1>nk2 then yer:=yer-2 else yer:=yer-1;
       if text='' then valueinteger:=0;
       selstart:=yer;
       exit;
     end;
   end; {case bitti}
end;
///**************************************************************************///
procedure TSrEditInt.WMPaint(var Message: TLMPaint);
begin
  if aktif=0 then inherited else rightlean(self);
end;
///**************************************************************************///
procedure TSrEditInt.rightlean(var xe: TEdit);
 var
  xl,xh : integer;
  xs    : string;
  xc    : TControlCanvas;
begin
  xs := xe.Text;
  while pos(ThousandSeparator,xs)<>0 do delete(xs,pos(ThousandSeparator,xs),1);
  xs:= StringReplace (xs, ThousandSeparator,  '', [rfReplaceAll]);
  xs := formatfloat(frm,strtofloat(xs));
  xc := Tcontrolcanvas.Create;
  xc.Control:=xe;
  xc.Lock;
  xc.Color:=color;
  xc.Font.Color:=font.Color;
  xc.FillRect(xe.ClientRect);
  xh := xc.TextWidth(xs);
  xl := xe.ClientRect.Right - xh - 7;
  xc.TextRect(xe.ClientRect, xl, 1, xs);
  xc.UnLock;
  xc.Free;
end;
///**************************************************************************///
initialization
{$I fshcompreg.lrs}
///**************************************************************************///
end.

matthijs

  • Hero Member
  • *****
  • Posts: 537
RE: component fshcomp
« Reply #3 on: January 24, 2006, 08:21:42 am »
Just an observation. :)
Could you explain why you are doing this:
Code: [Select]

  while pos(ThousandSeparator,edt)<>0 do
    delete(edt,pos(ThousandSeparator,edt),1);
  edt:= StringReplace (edt, ThousandSeparator, '', [rfReplaceAll]);

First you remove all ThousandSeparators and the you replace them with nothing. :) To me it seems you are trying to remove the ThousandSeparators twice.
This happens in DoExit and later again in RightLean.


BTW. Would you please put your code between code-tags? This would make it more readable! Thanks.
What's in a sig? Would my posting look less if it didnot have a sig? (Free after William S.) :)

:( Why cannot I upload my own Avatar? :(

dan

  • New Member
  • *
  • Posts: 11
RE: component fshcomp
« Reply #4 on: January 24, 2006, 09:57:23 am »
Oh yes, I forget delete lines with
Code: [Select]
while pos(ThousandSeparator,edt)<>0 do delete(edt,pos(ThousandSeparator,edt),1);
I will try completely re-write the source code in this coponent and make it more readable and multiplatform.

selimr

  • Guest
component fshcomp
« Reply #5 on: January 24, 2006, 02:24:41 pm »
SrEditInt

Code: [Select]

///**************************************************************************///
///************                                                  ************///
///************   SrEditInt ver : 2.00        selim reis         ************///
///************                                                  ************///
///************   lazarus components                             ************///
///************                                                  ************///
///************   reis_selim@hotmail.com      10/11/2005         ************///
///************                                                  ************///
///**************************************************************************///

unit SrEditInt;

{$mode objfpc}{$H+}

interface

///**************************************************************************///
uses
  Classes, SysUtils, LResources, Forms, Controls, windows,
  Graphics, Dialogs, StdCtrls, lmessages;
///**************************************************************************///

type

{ TSrEditInt }

  TSrEditInt = class(TEdit)

///**************************************************************************///
 private
   FColorActive       : TColor;
   FColorActiveText   : TColor;
   TColorActive       : Tcolor;
   TColorActiveText   : Tcolor;
   Frm                : string;
   FvalueInteger      : integer;
   aktif              : integer;
   nokta              : string;
   procedure gunvalueInteger(const Value: integer);
   procedure rightlean(var xe: TEdit);
///**************************************************************************///
protected
   procedure DoEnter; Override;
   procedure DoExit ; Override;
   procedure KeyPress (var Key: Char); Override;
   procedure WMPaint  (var Message: TLMPaint); message LM_PAINT;
///**************************************************************************///
public
   Constructor Create (AOwner : TComponent); Override;
///**************************************************************************///
published
   property Autosize;
   property BorderStyle;
   property Ctl3D;
   property Cursor;
   property DragCursor;
   property DragKind;
   property DragMode;
   property Enabled;
   property Font;
   property maxlength;
   property Name;
   property ParentColor;
   property parentCtl3D;
   property ParentFont;
   property ParentShowhint;
   property PopupMenu;
   property ReadOnly;
   property ShowHint;
   property TabOrder;
   property Text;
   property Visible;
   property OnChange;
   property OnClick;
   property OnDblClick;
   property OnDragDrop;
   property OnDragOver;
   property OnEndDrag;
   property OnEnter;
   property OnExit;
   property OnKeyDown;
   property OnKeyPress;
   property OnKeyUp;
   property OnMouseDown;
   property OnMouseMove;
   property OnMouseUp;
   property ValueInteger   :integer read FvalueInteger    write gunvalueInteger;
   property ColorActive    :TColor  read FColorActive     write FColorActive;
   property ColorActiveText:TColor  read FColorActiveText write FColorActiveText;
end;
///**************************************************************************///

procedure Register;

implementation

///**************************************************************************///

{ TSrEditInt }

///**************************************************************************///
procedure Register;
begin
   RegisterComponents('fsh', [TSrEditInt]);
end;
///**************************************************************************///
constructor TSrEditInt.Create(AOwner: TComponent);
  begin
    inherited Create (AOwner);
    nokta            := thousandseparator;
    frm              := ',0';
    FColorActive     := ClWhite;
    FColorActiveText := ClRed;
    ParentCtl3D      := False;
    Ctl3D            := False;
    Height           := 19;
    Color            := ClInfoBk;
    Font.Color       := ClBlue;
    width            := 120;
    Text             := '0';
    ValueInteger     := 0;
    aktif            := 1;
end;
///**************************************************************************///
procedure TSrEditInt.DoEnter;
  begin
    inherited;
    aktif            := 0;
    TColorActive     := color;
    TColorActiveText := font.Color;
    color            := fcoloractive;
    font.color       := fcoloractivetext;
  end;
///**************************************************************************///
procedure TSrEditInt.DoExit;
var
 edt: string;
  begin
    inherited;
    color        := TColorActive;
    font.color   := TColorActiveText;
    if text='' then edt:='0' else edt:= text;
    while pos(nokta,edt)<>0 do delete(edt,pos(nokta,edt),1);
    text         := formatfloat(frm,strtofloat(edt));
    valueInteger := strtoint(edt);
    aktif        := 1;
  end;
///**************************************************************************///
procedure TSrEditInt.gunvalueInteger(const Value: integer);
begin
  if fvalueInteger = Value then exit;
  FvalueInteger   := Value;
  text            := formatfloat(frm,valueinteger);
end;
///**************************************************************************///
procedure TSrEditInt.KeyPress(var Key: Char);
  var
   tus: char;
   edt: string;
   yer,nk1,nk2,i : integer;
begin
   inherited;
   tus := key;
   key := #0;
   yer := selstart;

   case tus of {case başla}
     #13 :
     begin
       PostMessage(Handle,WM_KEYDOWN,39,0);
       PostMessage(Handle,WM_KEYDOWN,09,0);
     end;
     '0'..'9' :
     begin
       if sellength=length(text) then text:='';
       nk1:=0;
       for i:=1 to length(Text) do if copy(Text,i,1)=nokta then nk1:=nk1+1;
       edt:=copy(text,1,yer)+tus+copy(text,yer+1,length(text));
       while pos(nokta,edt)<>0 do delete(edt,pos(nokta,edt),1);
       text:=formatfloat(frm,strtofloat(edt));
       nk2:=0;
       for i:=1 to length(Text) do if copy(Text,i,1)=nokta then nk2:=nk2+1;
       if nk2>nk1 then yer:=yer+2 else yer:=yer+1;
       selstart:=yer;
     end;
     #8 :
     begin
       nk1:=0;
       for i:=1 to length(Text) do if copy(Text,i,1)=nokta then nk1:=nk1+1;
       edt:=copy(text,1,yer-1)+copy(text,yer+1,length(text));
       while pos(nokta,edt)<>0 do delete(edt,pos(nokta,edt),1);
       if edt='' then edt:='0';
       text:=formatfloat(frm,strtofloat(edt));
       nk2:=0;
       for i:=1 to length(Text) do if copy(Text,i,1)=nokta then nk2:=nk2+1;
       if nk1>nk2 then yer:=yer-2 else yer:=yer-1;
       if text='' then valueinteger:=0;
       selstart:=yer;
       exit;
     end;
   end; {case bitti}
end;
///**************************************************************************///
procedure TSrEditInt.WMPaint(var Message: TLMPaint);
begin
  if aktif=0 then inherited else rightlean(self);
end;
///**************************************************************************///
procedure TSrEditInt.rightlean(var xe: TEdit);
 var
  xl,xh : integer;
  xs    : string;
  xc    : TControlCanvas;
begin
  xs := xe.Text;
  while pos(nokta,xs)<>0 do delete(xs,pos(nokta,xs),1);
  xs := formatfloat(frm,strtofloat(xs));
  xc := Tcontrolcanvas.Create;
  xc.Control:=xe;
  xc.Lock;
  xc.Color:=color;
  xc.Font.Color:=font.Color;
  xc.FillRect(xe.ClientRect);
  xh := xc.TextWidth(xs);
  xl := xe.ClientRect.Right - xh - 7;
  xc.TextRect(xe.ClientRect, xl, 1, xs);
  xc.UnLock;
  xc.Free;
end;
///**************************************************************************///
initialization
{$I fshcompreg.lrs}
///**************************************************************************///
end.




SrEditCur

Code: [Select]

///**************************************************************************///
///************                                                  ************///
///************   SrEditCur ver : 2.00        selim reis         ************///
///************                                                  ************///
///************   lazarus components                             ************///
///************                                                  ************///
///************   reis_selim@hotmail.com      10/11/2005         ************///
///************                                                  ************///
///**************************************************************************///

unit SrEditCur;

{$mode objfpc}{$H+}

interface

///**************************************************************************///
uses
  Classes, SysUtils, LResources, Forms, Controls, windows,
  Graphics, Dialogs, StdCtrls, lmessages;
///**************************************************************************///

type

{ TSrEditCur }

  TSrEditCur = class(TEdit)

///**************************************************************************///
 private
   nokta              : string;
   FColorActive       : TColor;
   FColorActiveText   : TColor;
   TColorActive       : Tcolor;
   TColorActiveText   : Tcolor;
   Fdecimal           : integer;
   Frm                : string;
   Fvaluefloat        : real;
   aktif              : integer;
   procedure gundecimal(const Value: integer);
   procedure gunvaluefloat(const Value: real);
   procedure rightlean(var xe: TEdit);
///**************************************************************************///
protected
   procedure DoEnter; Override;
   procedure DoExit ; Override;
   procedure KeyPress (var Key: Char); Override;
   procedure WMPaint  (var Message: TLMPaint); message LM_PAINT;
///**************************************************************************///
public
   Constructor Create (AOwner : TComponent); Override;
///**************************************************************************///
published
   property Autosize;
   property BorderStyle;
   property Ctl3D;
   property Cursor;
   property DragCursor;
   property DragKind;
   property DragMode;
   property Enabled;
   property Font;
   property maxlength;
   property Name;
   property ParentColor;
   property parentCtl3D;
   property ParentFont;
   property ParentShowhint;
   property PopupMenu;
   property ReadOnly;
   property ShowHint;
   property TabOrder;
   property Text;
   property Visible;
   property OnChange;
   property OnClick;
   property OnDblClick;
   property OnDragDrop;
   property OnDragOver;
   property OnEndDrag;
   property OnEnter;
   property OnExit;
   property OnKeyDown;
   property OnKeyPress;
   property OnKeyUp;
   property OnMouseDown;
   property OnMouseMove;
   property OnMouseUp;
   property Decimal        :Integer read Fdecimal     write gundecimal;
   property ValueFloat     :Real    read Fvaluefloat  write gunvaluefloat;
   property ColorActive    :TColor read FColorActive     write FColorActive;
   property ColorActiveText:TColor read FColorActiveText write FColorActiveText;
end;
///**************************************************************************///

procedure Register;

implementation

///**************************************************************************///

{ TSrEditCur }

///**************************************************************************///
procedure Register;
begin
   RegisterComponents('fsh', [TSrEditCur]);
end;
///**************************************************************************///
constructor TSrEditCur.Create(AOwner: TComponent);
  begin
    inherited Create (AOwner);
    nokta            := thousandseparator;
    FColorActive     := ClWhite;
    FColorActiveText := ClRed;
    ParentCtl3D      := False;
    Ctl3D            := False;
    Height           := 19;
    Color            := ClInfoBk;
    Font.Color       := ClBlue;
    width            := 120;
    Text             := '0,00';
    decimal          := 2;
    Valuefloat       := 0;
    aktif            := 1;
end;
///**************************************************************************///
procedure TSrEditCur.DoEnter;
  begin
    inherited;
    aktif            := 0;
    TColorActive     := color;
    TColorActiveText := font.Color;
    color            := fcoloractive;
    font.color       := fcoloractivetext;
  end;
///**************************************************************************///
procedure TSrEditCur.DoExit;
var
 edt: string;
  begin
    inherited;
    color      := TColorActive;
    font.color := TColorActiveText;
    if text='' then edt:='0' else edt:= text;
    while pos(nokta,edt)<>0 do delete(edt,pos(nokta,edt),1);
    text       := formatfloat(frm,strtofloat(edt));
    valuefloat := strtofloat(edt);
    aktif      := 1;
  end;
///**************************************************************************///
procedure TSrEditCur.gundecimal(const Value: integer);
begin
  if Fdecimal = Value then exit;
  Fdecimal   := Value;
  if decimal  = 0 then frm := ',0' else frm := ',0.'+ stringofchar('0',decimal);
  text       := formatfloat(frm,valuefloat);
end;
///**************************************************************************///
procedure TSrEditCur.gunvaluefloat(const Value: real);
begin
  if fvaluefloat = Value then exit;
  Fvaluefloat   := Value;
  text          := formatfloat(frm,valuefloat);
end;
///**************************************************************************///
procedure TSrEditCur.KeyPress(var Key: Char);
  var
   tus: char;
   edt: string;
   yer,nk1,nk2,i : integer;
begin
   inherited;
   tus := key;
   key := #0;
   yer := selstart;

   case tus of {case başla}
     #13 :
     begin
       PostMessage(Handle,WM_KEYDOWN,39,0);
       PostMessage(Handle,WM_KEYDOWN,09,0);
     end;
     ',','.' : if decimal<>0 then selstart:=pos(decimalseparator,text);
     '0'..'9' :
     begin
       if sellength=length(text) then text:='';
       nk1:=0;
       for i:=1 to length(Text) do if copy(Text,i,1)=nokta then nk1:=nk1+1;
       edt:=copy(text,1,yer)+tus+copy(text,yer+1,length(text));
       while pos(nokta,edt)<>0 do delete(edt,pos(nokta,edt),1);
       text:=formatfloat(frm,strtofloat(edt));
       nk2:=0;
       for i:=1 to length(Text) do if copy(Text,i,1)=nokta then nk2:=nk2+1;
       if nk2>nk1 then yer:=yer+2 else yer:=yer+1;
       selstart:=yer;
     end;
     #8 :
     begin
       nk1:=0;
       if ((yer+1>pos(',',text)) and (decimal>0)) then
       begin
       if yer>pos(',',text) then
       begin
       text:=copy(text,1,yer-1)+'0'+copy(text,yer,length(text)-1);
       postmessage(handle,WM_KEYDOWN,46,0);
       end;
       postmessage(handle,WM_KEYDOWN,37,0);
       selstart:=yer;
       exit;
       end;
       for i:=1 to length(Text) do if copy(Text,i,1)=nokta then nk1:=nk1+1;
       edt:=copy(text,1,yer-1)+copy(text,yer+1,length(text));
       while pos(nokta,edt)<>0 do delete(edt,pos(nokta,edt),1);
       if edt='' then edt:='0';
       text:=formatfloat(frm,strtofloat(edt));
       nk2:=0;
       for i:=1 to length(Text) do if copy(Text,i,1)=nokta then nk2:=nk2+1;
       if nk1>nk2 then yer:=yer-2 else yer:=yer-1;
       if text='' then valuefloat:=0;
       selstart:=yer;
       exit;
     end;
   end; {case bitti}
end;
///**************************************************************************///
procedure TSrEditCur.WMPaint(var Message: TLMPaint);
begin
  if aktif=0 then inherited else rightlean(self);
end;
///**************************************************************************///
procedure TSrEditCur.rightlean(var xe: TEdit);
 var
  xl,xh : integer;
  xs    : string;
  xc    : TControlCanvas;
begin
  xs := xe.Text;
  while pos(nokta,xs)<>0 do delete(xs,pos(nokta,xs),1);
  xs := formatfloat(frm,strtofloat(xs));
  xc := Tcontrolcanvas.Create;
  xc.Control:=xe;
  xc.Lock;
  xc.Color:=color;
  xc.Font.Color:=font.Color;
  xc.FillRect(xe.ClientRect);
  xh := xc.TextWidth(xs);
  xl := xe.ClientRect.Right - xh - 7;
  xc.TextRect(xe.ClientRect, xl, 1, xs);
  xc.UnLock;
  xc.Free;
end;
///**************************************************************************///
initialization
{$I fshcompreg.lrs}
///**************************************************************************///
end.


dan

  • New Member
  • *
  • Posts: 11
component fshcomp
« Reply #6 on: January 24, 2006, 03:35:58 pm »
And here is it: http://www.mivazlin.cz/danielvals/fshcomp2.01.zip . I removed windows unit and added clipboard support. Please try it. Thanks   :shock:

matthijs

  • Hero Member
  • *****
  • Posts: 537
component fshcomp
« Reply #7 on: January 24, 2006, 05:58:27 pm »
Two observations. :)
1. You make your components a descendant of TEdit. What you should do in cases like this, is use TCustomEdit as ancestor.
2. In the definition of your class you only have to mention the properties/methods that get a higher visibility or get overriden. So in your case all properties like OnClick you do not have to repeat.

I do not want to critisize you, I only want to give helpfull hints. (And hope other readers may learn in the process. :) )
What's in a sig? Would my posting look less if it didnot have a sig? (Free after William S.) :)

:( Why cannot I upload my own Avatar? :(

Vincent Snijders

  • Administrator
  • Hero Member
  • *
  • Posts: 2661
    • My Lazarus wiki user page
component fshcomp
« Reply #8 on: January 24, 2006, 08:34:28 pm »
If you want you can create a page on the wiki like TAChart, for example here. Then I will put the component on the lazarus-ccr sourceforge site, where it is much more visible.

dan

  • New Member
  • *
  • Posts: 11
component fshcomp
« Reply #9 on: January 25, 2006, 10:11:29 am »
Quote from: "Vincent"
If you want you can create a page on the wiki like TAChart, for example here. Then I will put the component on the lazarus-ccr sourceforge site, where it is much more visible.

I created simple page  on wiky

dan

  • New Member
  • *
  • Posts: 11
component fshcomp
« Reply #10 on: January 25, 2006, 10:19:08 am »
Quote from: "matthijs"
Two observations. :)
1. You make your components a descendant of TEdit. What you should do in cases like this, is use TCustomEdit as ancestor.
2. In the definition of your class you only have to mention the properties/methods that get a higher visibility or get overriden. So in your case all properties like OnClick you do not have to repeat.

I do not want to critisize you, I only want to give helpfull hints. (And hope other readers may learn in the process. :) )

I changed an ancestor as TCustomEdit, but I do not understand your second observation. Can you give me any sample?
New version is here

matthijs

  • Hero Member
  • *****
  • Posts: 537
component fshcomp
« Reply #11 on: January 25, 2006, 12:38:28 pm »
All right, I'll try to. :)
Code: [Select]

TmyObject  = class
  private
    property aPrivateProp: Something;
    procedure aPrivateProc;
    function aPrivateFunc: Integer; override;
  public
    property aPublicProp: Anything;
  published
    property aPuplishedProp: Whatever;
end;
 
TmyDerObject = class(TmyObject)
  private
    function aPrivateFunc: Integer; override;
  public
    procedure aPrivateProc;
  published
    property aPublicProp: Anything;
end;

In the second class definition aPublicProp is repeated because it is made published. The function is redifined because we override it and the procedure is defined because we gave it a higher visibility.
All the other members of TmyObject are available, but because they are not changed they do not have to be mentioned in the second class.
I hope this is clear, or maybe somebody else can explain it better. :)

Remember it is always posible to give a member of a class a higher visibility (from protected to private, or from private to public) but not the toher way around.
Example. Text propery of TEdit is published, if you make a new class from TEdit you can not make it public or private.
What's in a sig? Would my posting look less if it didnot have a sig? (Free after William S.) :)

:( Why cannot I upload my own Avatar? :(

Vincent Snijders

  • Administrator
  • Hero Member
  • *
  • Posts: 2661
    • My Lazarus wiki user page
component fshcomp
« Reply #12 on: January 25, 2006, 12:42:49 pm »
I added the 2.2.1.1 version (number from the lpk file) to the Lazarus CCR download area.

 

TinyPortal © 2005-2018