| View previous topic :: View next topic |
| Author |
Message |
rapion124 Grandmaster Cheater Supreme
Reputation: 0
Joined: 25 Mar 2007 Posts: 1095
|
Posted: Mon Dec 17, 2007 7:52 pm Post subject: [Delphi] Inheritance |
|
|
| Is there anyway to create and use more than 1 instance of an object and have the created objects be derived from the original? For example, I wanna use 20 separate labels in my program. Instead of creating 20 labels at design time, is there a way to create only 1 at degisn time and have all the other 19 be derived from that one? Like in C, you can create objects based on another objects. Is there a way to do that in Delph?
|
|
| Back to top |
|
 |
Uzeil Moderator
Reputation: 6
Joined: 21 Oct 2006 Posts: 2411
|
Posted: Tue Dec 18, 2007 1:46 pm Post subject: |
|
|
A good example of dynamic component creation in Delphi: CE's pointer form(add manual address).
_________________
|
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 471
Joined: 09 May 2003 Posts: 25857 Location: The netherlands
|
Posted: Tue Dec 18, 2007 2:15 pm Post subject: |
|
|
you can create a special tpanel class (inherit from the original tpanel) called Tmystuff and on there place the labels.
Then in your code you can create 20 of those
And then create multiple TMyStuff objects and place them on the form at runtime. (setting the parent)
e.g: inheriting from a previous class:
type TMyclass=class(classtoinheritfrom)
public
...
private
...
protected
...
etc
...
end;
for more specific stuff, look up inhertance in the helpfile, it's not difficult.
Just not sure if it supports inheriting from 2 or more classess like C can, but ising interfaces you can
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
| Back to top |
|
 |
Uzeil Moderator
Reputation: 6
Joined: 21 Oct 2006 Posts: 2411
|
Posted: Tue Dec 18, 2007 6:07 pm Post subject: |
|
|
I thought he was talking about creating objects based on others for run-time? Although your interpretation would explain why he called it inheritence(Even though you can inherit traits from other objects during object creation).
For procedure overwriting, use the keyword override after the procedure(ctrl+shift+c while having the cursor in the procedure title will set up with with default settings for it's overridden procedure(like starting out with the keyword inherited; )
_________________
|
|
| Back to top |
|
 |
mOnSoOn Expert Cheater
Reputation: 0
Joined: 05 Jul 2007 Posts: 203
|
Posted: Fri Dec 21, 2007 5:07 am Post subject: |
|
|
Inheritance
|
|
| Back to top |
|
 |
|