LMuadDIb
asked on
adding properties to an object
hey all,
Im working with an indy nttp client, and I made it multi-threaded ( connecting )
and I create the objects dynamically, but I was wondering if its possible to create additional properties for each nttp object
I want to store more information within each individual object, like add the property how many such and such that the normal indy client doesnt hold.
DO I have to adjust the indy clients code directly and recompile the source code for TidNNTP, or can I just add to it indirectly from within my own app?
indirectly using my own class and be able to reference my class from within the indy object:
type
TNNTPCustProps = class
private
FGroupCount: integer;
procedure SetGroupCount(const Value: Integer);
public
// --- THE CUstom idNTTP PROPERTIES -----
property GroupCount: integer read FGroupCount write SetGroupCount;
end;
var
NNTPprops: TNNTPCustProps;
implementation
{ TCustomNNTP Properties }
procedure TNNTPCustProps .SetGroupCount(const Value: integer);
begin
FGroupCount := Value;
end;
then access this property from within the indy nntp object like so:
var
IdNNTP1 : TIdNNTP;
begin
IdNNTP1 := TIdNNTP1.create(self);
IdNNTP1 .GroupCount := 0;
// etc..............
thanx in advance
Im working with an indy nttp client, and I made it multi-threaded ( connecting )
and I create the objects dynamically, but I was wondering if its possible to create additional properties for each nttp object
I want to store more information within each individual object, like add the property how many such and such that the normal indy client doesnt hold.
DO I have to adjust the indy clients code directly and recompile the source code for TidNNTP, or can I just add to it indirectly from within my own app?
indirectly using my own class and be able to reference my class from within the indy object:
type
TNNTPCustProps = class
private
FGroupCount: integer;
procedure SetGroupCount(const Value: Integer);
public
// --- THE CUstom idNTTP PROPERTIES -----
property GroupCount: integer read FGroupCount write SetGroupCount;
end;
var
NNTPprops: TNNTPCustProps;
implementation
{ TCustomNNTP Properties }
procedure TNNTPCustProps .SetGroupCount(const Value: integer);
begin
FGroupCount := Value;
end;
then access this property from within the indy nntp object like so:
var
IdNNTP1 : TIdNNTP;
begin
IdNNTP1 := TIdNNTP1.create(self);
IdNNTP1 .GroupCount := 0;
// etc..............
thanx in advance
type
TNNTPCustProps = class(TidNNTP)
private
FGroupCount: integer;
procedure SetGroupCount(const Value: Integer);
public
// --- THE CUstom idNTTP PROPERTIES -----
property GroupCount: integer read FGroupCount write SetGroupCount;
end;
var
NNTPprops: TNNTPCustProps;
implementation
{ TCustomNNTP Properties }
procedure TNNTPCustProps .SetGroupCount(const Value: integer);
begin
FGroupCount := Value;
end;
then access this property from within the indy nntp object like so:
var
IdNNTP1 : TIdNNTP;
begin
IdNNTP1 := TIdNNTP1.create(self);
IdNNTP1 .GroupCount := 0;
// etc..............
TNNTPCustProps = class(TidNNTP)
private
FGroupCount: integer;
procedure SetGroupCount(const Value: Integer);
public
// --- THE CUstom idNTTP PROPERTIES -----
property GroupCount: integer read FGroupCount write SetGroupCount;
end;
var
NNTPprops: TNNTPCustProps;
implementation
{ TCustomNNTP Properties }
procedure TNNTPCustProps .SetGroupCount(const Value: integer);
begin
FGroupCount := Value;
end;
then access this property from within the indy nntp object like so:
var
IdNNTP1 : TIdNNTP;
begin
IdNNTP1 := TIdNNTP1.create(self);
IdNNTP1 .GroupCount := 0;
// etc..............
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Missed his creation of his object.
Paulb1989 is correct with how to create your object.
Paulb1989 is correct with how to create your object.
This means you inherit from it but you can add your owns properties to it like you are doing.