How "heavy" are the respective class hierarchy levels?
From: Raptor (bogus_at_none.com)
Date: 01/31/05
- Next message: Jamie: "Re: How "heavy" are the respective class hierarchy levels?"
- Previous message: J West: "Re: can Delphi4 use MSAccess2003 tables?"
- Next in thread: Jamie: "Re: How "heavy" are the respective class hierarchy levels?"
- Reply: Jamie: "Re: How "heavy" are the respective class hierarchy levels?"
- Reply: Rob Kennedy: "Re: How "heavy" are the respective class hierarchy levels?"
- Reply: Maarten Wiltink: "Re: How "heavy" are the respective class hierarchy levels?"
- Reply: Marc Rohloff [TeamB]: "Re: How "heavy" are the respective class hierarchy levels?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 30 Jan 2005 19:52:31 -0800
Anyone have a feel for how heavy the respective class hierarchy levels
really are? By "heavy" I mean, of course, how much memory they would
require, comparatively? (Factor in anything else you feel contributes to
"weight" or whatever metaphor you choose.)
Presumably the lightest class level a component writer or programmer would
use is TPersistent. Also presumably, a programmer would seek to use the
simplest class commensurate with programming needs. The levels would be:
TPersistent
|
|
TComponent
|
|
TControl
|
|
TWinControl or TGraphicControl
I've started writing a component whose behavior requires that I know when
the application is loaded. Some deviously evil person named Maarten,
cleverly disguised as a helpful soul, suggested that my code simply send
itself a message, because messages are handled when loading is complete.
Well, TComponents don't have handles, and I can't figure out how to send
and receive a message (within one context) without a handle. Hmmm, TControls
don't have handles, either. Well, I'll just crank out a temporary
TWinControl which will send and receive its own message and be done with it.
But that TWinControl just sits on the curb pouting because it's an orphan
and needs a parent. "Waaah. I want a parent! Gimme a parent. Any parent. I
refuse to do anything until you do."
"C'mon," I respond. "You're sitting here in your own unit and everyone will
laugh at me if I just appoint 'formMain' as your parent. Talk about being a
dependant."
"What about the component class? Maybe I can share its parent."
"Well, maybe. I'll have to promote it to TControl, though, as TComponents
don't have parents."
"So do it already," the brat TWinControl snapped.
The field promotion was unceremonious. Yet TWinControl still refused to
budge.
"Stupid," he snarled. "How can I share TTranslate's parent if he's an orphan
too?"
"You've got a point there," I said, dashing off to the form which tests my
would-be component. "Here..."
procedure TformMain.FormCreate(Sender: TObject);
begin
aTranslate := TTranslate.Create(self);
aTranslate.Parent := self;
"and now I'll just..."
constructor TTranslate.Create(aOwner: TComponent);
begin
inherited Create(aOwner);
aTheTWinControl:= TTheTWinControl.Create(aOwner);
aTheTWinControl.Parent := self.Parent;
"ahhh... that should do it."
But it didn't. Junior still needs a mommy. Those with about five minutes
experience will immediately see why.
* Perhaps I could promote TTranslate to a TWinControl so it has a handle,
but this is going to stay in memory. Just how much extra room would that
little fatty take?
* I read that somewhere if this were a full-fledged Registered control, it
would automatically get the form as a parent if t'were plopped on as a
visual component.
"But Doctor, Doctor, it still hurts when I create one dynamically."
"Well, don't do that." Bah-dum-bum.
The End
=====================
What's the price of TWinControl vs. TComponent?
Barring that, any strategies for dynamically obtaining a parent, any parent,
for a transitory invisible control?
Barring that, are Ya-Really-DO-Gotta-Drop-This-On-a-Form controls really
evil? Maybe they're just misunderstood and need love. Heh.
Raptor
- Next message: Jamie: "Re: How "heavy" are the respective class hierarchy levels?"
- Previous message: J West: "Re: can Delphi4 use MSAccess2003 tables?"
- Next in thread: Jamie: "Re: How "heavy" are the respective class hierarchy levels?"
- Reply: Jamie: "Re: How "heavy" are the respective class hierarchy levels?"
- Reply: Rob Kennedy: "Re: How "heavy" are the respective class hierarchy levels?"
- Reply: Maarten Wiltink: "Re: How "heavy" are the respective class hierarchy levels?"
- Reply: Marc Rohloff [TeamB]: "Re: How "heavy" are the respective class hierarchy levels?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|