>I have come across this situation occasionally, but when I do the first
>things that I think about is if the required behaviour modification can
be
>achieved by taking the base class and adding an event notification that
>can be published and used to handle the special case.
>
>In 80% of the cases I have struck the 'special case' is really a
behaviour
>modification or drawing change that an event can support easily. This
is
>usually accompanied by a realisation that the component in question
>should
>have had the event in the first place, but when I wrote it is 'saved
time'
>by not including it.
>
>The other 20% are a change that alters a components behaviour so much
>that
>I then start looking at what I really want to achieve and start
thinking
>about building a new component that supports what is needed.
Your 80%/20% point is a good one for components that you wrote yourself.
In that case you're always able to rewrite as you see fit. But what
about when you want to modify a third-party component? For example,
when making a change to one of the basic Delphi components, you have the
choice to inherit immediately and use that descendant class everywhere.
There's much to be said for that. Also, the component may well have
several events that you can use to implement your functionality. But if
you haven't already subclassed the component, and things become untidy
if you have to manipulate many events to add your functionality, then
the way of subclassing I suggest would be a very clean alternative.
Concise and clear.
>The real issue is that if you can created new component type on a form
>then you must be able to stream the component in and out cleanly. If
the
>component makes any modification at all to the published properties
then
>you need compiled code and RTTI information for the streaming to work.
>The
>IDE is going to have to compile and generate RTTI at design time to
>support streaming. If the code doesn't compile then the custom
component
>just can't be streamed out (not so bad) or in (really annoying).
>
>For all its magic the IDE doesn't actually compile code in the design
>environment. Internally there is a parser that does all the parsing to
>allow the property editors to work, the code completion to work and the
>navigation features, but it never produces any code until you choose to
>compile a unit. Enhacing the IDE to do partial compiles and links at
>design time to extend the IDE is a very big ask.
I'm not looking to place a derived component on the form at design time,
only create it at runtime. I agree with you that the former would be a
big ask. But creating a derived instance of a component at runtime, and
streaming into that instead, is not. The idea being that your button is
a TButton, and looks and behaves as one, in the IDE. It's only when
it's created at runtime that it's created as a TMyButton, which can have
its properties set from the form resource just as any TButton could
(assuming you can have a successful cast "TButton as TMyButton"). All
you need is your standard runtime RTTI.
Cheers,
Carl Reynolds Ph: +64-9-4154790
CJN Technologies Ltd. Fax: +64-9-4154791
[EMAIL PROTECTED] DDI: +64-9-4154795
PO Box 302-278, North Harbour, Auckland, New Zealand
12 Piermark Drive, North Harbour Estate, Auckland, NZ
Visit our website at http://www.cjntech.co.nz/
> -----Original Message-----
> From: Max Nilson [SMTP:[EMAIL PROTECTED]]
> Sent: Thursday, September 23, 1999 5:41 PM
> To: Multiple recipients of list offtopic
> Subject: RE: [DUG-OFFTOPIC]: DELPHI WISH LIST - subclass form
> components
>
> Carl Reynolds asked
>
> > Come on everyone, haven't any of you ever wanted to subclass a
> component
> > on a form without either sticking yet another
> >
> "TAnotherSubclassedComponentThatsNeededForOneParticularFormButICouldnt
> Te
> > llYouWhyOrWhatItDoesWithoutLookingAtItAgain" component into the
> > component palette, or creating and keeping track of "helper
> objects"?
>
> I have come across this situation occasionally, but when I do the
> first
> things that I think about is if the required behaviour modification
> can be
> achieved by taking the base class and adding an event notification
> that
> can be published and used to handle the special case.
>
> In 80% of the cases I have struck the 'special case' is really a
> behaviour
> modification or drawing change that an event can support easily. This
> is
> usually accompanied by a realisation that the component in question
> should
> have had the event in the first place, but when I wrote it is 'saved
> time'
> by not including it.
>
> The other 20% are a change that alters a components behaviour so much
> that
> I then start looking at what I really want to achieve and start
> thinking
> about building a new component that supports what is needed.
>
> > One of the advantages of my suggestion is that it would be very easy
> to
> > implement. One tiny extra situation to check for during a compile
> and a
> > slight relaxing of the loading rules - that's it! :)
>
> The real issue is that if you can created new component type on a form
> then you must be able to stream the component in and out cleanly. If
> the
> component makes any modification at all to the published properties
> then
> you need compiled code and RTTI information for the streaming to work.
> The
> IDE is going to have to compile and generate RTTI at design time to
> support streaming. If the code doesn't compile then the custom
> component
> just can't be streamed out (not so bad) or in (really annoying).
>
> For all its magic the IDE doesn't actually compile code in the design
> environment. Internally there is a parser that does all the parsing to
> allow the property editors to work, the code completion to work and
> the
> navigation features, but it never produces any code until you choose
> to
> compile a unit. Enhacing the IDE to do partial compiles and links at
> design time to extend the IDE is a very big ask.
>
> Cheers, Max.
>
>
> ----------------------------------------------------------------------
> -----
> New Zealand Delphi Users group - Offtopic List -
> [EMAIL PROTECTED]
> Website: http://www.delphi.org.nz
application/ms-tnef