TIP: Click on subject to list as thread! ANSI
echo: delphi
to: VITALIK MELEHIN
from: TING-CHIAO CHU
date: 1997-06-10 20:00:00
subject: TEdit-like element

Hallo Vitalik,
On 07-06-97 at 00:05:06 you wrote to All:
 VM> Hi, All!
 VM>   Tell me plz somebody: Do have Delphi2 standart TEdit-like element,
 VM> that work with Integer, etc. types, but not with string? Thanx.
No, but you can write your own components, for example (Delphi 1.0 code):
======================================================
TLongEdit = class(TEdit)
private
  Function  GetData : LongInt;
  Procedure SetData(aLong : LongInt);
public
  Constructor Create(aOwner : TComponent); Override;
published
  Property Text : LongInt read GetData write SetData;
end;
procedure Register;
{************************} implementation {************************}
procedure Register;
begin
  RegisterComponents('MyEdits', [TLongEdit]);
end;
{-------------------------------------------------------------------}
Constructor TLongEdit.Create;
  begin
    Inherited Create(aOwner);
    Inherited Text := '0';
  end;
{-------------------------------------------------------------------}
Function  TLongEdit.GetData;
  begin
    Try
      GetData := StrToInt(Inherited text);
    except
      GetData := 0;
    end;
  end;
{-------------------------------------------------------------------}
Procedure TLongEdit.SetData(aLong : LongInt);
  begin
    Inherited text := IntToStr(aLong);
  end;
======================================================
Some checking should be added to make the component foolproof. 
The property TEXT can be accessed as if it is an integer (besides some 
exceptions).
   _____
GR. |cc
--- FleetStreet 1.19+
---------------
* Origin: ?? (2:284/420.11)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.