Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > VCL

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 07-14-2016, 10:27 AM
lexd lexd is offline
Senior Member
 
Join Date: Feb 2015
Posts: 268
Default Joining 2 objects in a class - rules

I have A connection object derived from TObject that is key in a descendant object.
I want to combine this connection object to TComponent
Example :-
HTML Code:
 TCon = class(TObject)
   protected
    FActive: Boolean; 
    function GetActive: Boolean; virtual; abstract;
    procedure SetActive(const Value: Boolean); virtual; abstract;
    Function GetDataPostion(RecPos, Size: Integer): Pointer; virtual; abstract;
   Published
    property Active: Boolean read GetActive write SetActive default False;
  End;
From this I build my main object that many added objects use in the main object. This all works very well and is quite complicated to flow.

I want to now build a TComponent descendant that recognises TCon
Its got to look like a descendant of TCon so other added objects can see this descendant object is a TCon descendant.

I thought may be I should make my rather first major object Component too.
Or

HTML Code:
MyMajorComponet = class(TComponent, TCon)
    FCon: TCon;  // is this needed or incorrect?
    FActive: Boolean; 
    function GetActive: Boolean; override;
    procedure SetActive(const Value: Boolean); override;
    Function GetDataPostion(RecPos, Size: Integer): Pointer; override;
   Published
    property Active: Boolean read GetActive write SetActive default False;
  End;

MyMajorComponet.function GetActive: Boolean; 
Begin
.................
end;

MyMajorComponet.procedure SetActive(const Value: Boolean);
Begin
.............
end;

MyMajorComponet.Function GetDataPostion(RecPos, Size: Integer): Pointer;
Begin
................
end;
What would you do.
Reply With Quote
  #2  
Old 07-15-2016, 07:27 AM
Norrit Norrit is offline
Moderator
 
Join Date: Aug 2001
Location: Landgraaf
Posts: 7,335
Default

Code:
MyMajorComponet = class(TCon)
    FActive: Boolean; 
    function GetActive: Boolean; override;
    procedure SetActive(const Value: Boolean); override;
    Function GetDataPostion(RecPos, Size: Integer): Pointer; override;
   Published
    property Active: Boolean read GetActive write SetActive default False;
  End;

MyMajorComponet.function GetActive: Boolean; 
Begin
.................
end;

MyMajorComponet.procedure SetActive(const Value: Boolean);
Begin
.............
end;

MyMajorComponet.Function GetDataPostion(RecPos, Size: Integer): Pointer;
Begin
................
end;
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:32 AM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.