Re: Elementary Qs on objects

From: Rob Kennedy (me3_at_privacy.net)
Date: 01/27/05


Date: Thu, 27 Jan 2005 14:51:30 -0600

Raptor wrote:
> Two extra points for using the word "elided," three if you're an American.
> Heh.

Thanks, I think. Not sure whether to feel flattered or patronized.

> How might I best ensure that all components on all forms and in all units
> (including dynamically created) will be created BEFORE the component does
> its scan?

Well, as Marc and Maarten said, you can't really do that. What you can
do instead is have your translator be notified when new objects are
created that need translating.

> The best solution would be one where the component user does not have to
> remember to do This before That or manually place This code in That place.
> Barring that, I'll take what I can get to ensure reliable operation.

You should take a look at Mike Lischke's TThemeManager component. What
it does is subclass its owner -- inserting its own code in place of some
of its owner's routines -- so that it can get notification whenever its
owner gets a new component. It needs this so it can automatically
subclass those new components to add XP-style painting to them; you
would use the same technique to know when new components need translating.

TThemeManager also has a method to manually "collect" a control and
everything it contains. This is useful if the controls got created
before TThemeManager had a chance to insert its hook, or when a control
somehow got created without TThemeManager's knowledge. This serves as a
fallback method in case the automatic collection doesn't work. It
doesn't happen often, and it's pretty easy to detect when collection is
needed: The forms aren't painted right, or they aren't in the right
language.

Bruce mentioned overriding Notification; that's the ideal solution for
when you can be assured that all translatable components will be owned
by descendants of that overridden base class. But that situation is hard
to guarantee when working with an already-established class hierarchy,
like the VCL. TThemeManager inserts its code in the middle of the
hierarchy. It's a hack, but sometimes hacks are necessary.

-- 
Rob


Relevant Pages

  • Re: Elementary Qs on objects
    ... > Raptor wrote: ... > You should take a look at Mike Lischke's TThemeManager component. ... > would use the same technique to know when new components need translating. ... to its own ini file (as well as the language in use, ...
    (alt.comp.lang.borland-delphi)
  • Re: Problem with .properties("...")
    ... The DAO object may have that but the VB Form object does not. ... the control and the name of the property I want to translate as two ... one for translating DAO properties and one for translating ...
    (microsoft.public.vb.enterprise)
  • =?ISO-8859-1?Q?Re=3A_Cubic_B=2DSpline_to_B=E9zier?=
    ... Translating from b-spline control points for use in a Cubic Bezier ...
    (comp.graphics.algorithms)
  • Re: how to convert this (right version)?
    ... any particular reason you're translating this to JScript? ... control itself is IE/Windows only, ...
    (microsoft.public.scripting.jscript)
  • =?iso-8859-1?q?Re:_wikipedia_question=CA=F2?=
    ... someone else will try to control it to say what they want it to. ... Hmm. ... I'm translating a "starred" and clearly better article. ... that whoever wrote the current article will prick up their ears and ...
    (sci.lang.japan)