Delphic mysteries
Any large and complex tool is bound to have hidden nooks
and crannies and Delphi 5 is no exception.
Delphi 5 sports a new set of flamboyant marketing features
with names like ADO Express, InterBase Express, and Internet
Express -- the perfect complement to my daily dose of Italian
espresso. The new Delphi also offers an updated IDE,
international support, TeamSource, the Data Module Designer,
the ApplicationEvents component, the OnContextMenu event, and
an updated version of MIDAS. These and many other features are
carefully listed in the Delphi 5 "What's New" on-line help page.
Although the list of the new features described in the
on-line marketing literature and technical documentation is
large, not every new feature is listed there. Some secrets are
documented but hard to find and others are almost completely
undocumented. However, we have the source code, so nothing is
totally undocumented -- except the proxies unit. Some of these
features have been discussed elsewhere and this is far from a
complete list. But these are my favorite new secrets.
Navigational aids
The new Object Inspector has many great features -- some of
them not obvious. For example, wherever a property refers to a
component you can now Ctrl-double-click on the property value
(the referenced component) to load the other component into
the Object Inspector. This is a handy way of moving from one
component to another linked one. This is similar to the
Ctrl-click navigation offered in the editor since Delphi
4.
You probably know that Delphi 5's Object Inspector includes
graphical drop down lists. Besides cursors, images, and other
graphical elements, you can tune the IDE to display a
graphical drop down list of fonts, instead of a plain one.

Unfortunately, there isn't an Environment Option to turn on
this feature -- not even an undocumented registry setting. To
use the feature you need to create a package, and add a unit
that sets a global Boolean variable to True in the unit's
initialization section. The variable,
FontNamePropertyDisplayFontName, beats
TwoDigitYearCenturyWindow in the longest variable name
contest. The code
to make it work is extremely simple and is sort of documented.
There is a source code comment describing this property buried
in the 4k lines of the DsgnIntf unit. The associated comment
warns "Enable it at your own risk," as this can affect the
rendering operation on a slow computer with hundreds of fonts
installed.
The VCL also has many new features. One, which is fully
described, is the new FreeAndNil procedure that frees the
object passed to it as a parameter and sets the reference to
nil. At the opposite end of the documentation spectrum, there
is almost no mention of the new GetPropValue function of the
TypInfo unit (a unit that was heavily updated in the Delphi 5
release). You call this function with a component and the name
of a property of the component; it returns a variant with the
property's value:
strBtnCaption := GetPropValue (Button1,
'Caption');
Optionally you can pass a third parameter to get a textual
description of a setting instead of its actual value. In the
TypInfo source code you'll find a reasonable amount of
information, and, again, an example might help you figure out how to use
the function. The example includes the more complex code (now
commented out) required in past versions of Delphi to achieve
the same effect.
Menu mania
There are new features related to menu captions and
accelerator keys. Delphi 5 can add accelerator keys to menus
when you forget to include the ampersand, or when two
accelerator keys are conflicting -- something hard to
determine if you create the menu dynamically. This capability
is set using the AutoHotkeys property. Note that AutoHotkeys
is on by default and can cause problems if your program relies
on the text of the captions. Along with these new features,
the Menus unit includes two new global routines, StripHotkeys
and GetHotkey. These are fully described in the help files.
The individual menu items and submenus can have specific
ImageLists connected, so you don't need a single image list
for the entire menu.
You might not have noticed that there are new default
actions for the ActionList component. These actions are mainly
related to help operations but also offer some new edit
actions.
The new TMask class defined in the masks unit (not to be
confused with the mask unit, which has no final
s) allows the comparison of strings with wildcards. The
mechanism is quite powerful, but Borland managed to hide this
new feature in the TMask.Create VCL help entry.
I like one additional VCL feature a lot: main forms now
behave properly when minimized and restored. With Delphi 5,
applications now show the Windows animation effects and
produce the associated system sounds. Although the sounds were
easy to code in Delphi 4, the animation was difficult. This is
not the only new feature related to Windows support. The
common controls have been updated and menu items are now
Windows 2000-ready.
This is far from a complete list of Delphi 5 secrets. (I
mentioned you can type Alt+JEDI in the about box in my IDE article.) Borland is certainly doing a
better job of listing new features and providing complete and
readily available help files than it has in the past. There is
now a list of units, each with a list of routines and classes.
And the categorized list of routines -- missing since Delphi 1
-- has resurfaced. Additionally, the source code includes many
property editors and designers. Fortunately for those of
us who write articles and books, however, something always
seems to slip by. I should mention that a lot of these
features were shared with me by members of the Delphi R&D
team.
If you haven't upgraded to Delphi 5 yet, I have a list of Delphi 4 hidden features which are
still undocumented -- including the hidden registry settings.
And if you've discovered other hidden Delphi 5 features send them my way and
I'll spread them to the rest of the
community.
Originally written for InPublishing LLC for publication by Inprise Corp. Copyright 1999 Inprise Corp.
|