?
Solved

adding properties to an object

Posted on 2005-03-19
4
Medium Priority
?
149 Views
Last Modified: 2013-11-23
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







0
Comment
Question by:LMuadDIb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 15

Expert Comment

by:mikelittlewood
ID: 13582864
Do what you are doing now, but make your object of class TidNNTP.
This means you inherit from it but you can add your owns properties to it like you are doing.
0
 
LVL 15

Expert Comment

by:mikelittlewood
ID: 13582869
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..............
0
 
LVL 5

Accepted Solution

by:
paulb1989 earned 1000 total points
ID: 13582972
I think the above is slightly wrong, use:

var
  IdNNTP1 : TNNTPCustProps;
begin
  IdNNTP1 := TNNTPCustProps.create(self);
  IdNNTP1 .GroupCount := 0;
  // etc..............
0
 
LVL 15

Expert Comment

by:mikelittlewood
ID: 13583201
Missed his creation of his object.
Paulb1989 is correct with how to create your object.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses
Course of the Month10 days, 10 hours left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question