(Text version)
Borland Delphi
[ City Zoo | Announcements | Articles | Tips & Tricks | Bug List | FAQ | Sites ]


Tidbits from Delphi TechForum 95

As presented by Jim Karabatsos
written by Gary McGhee

Here are some notes I took from the 3 day Delphi TechForum in Perth a few weeks ago. By the way, it was a solid introduction to Delphi and had plenty of meat for moderately experienced Delphi users as well. Jim obviously knows his stuff and has used the product quite a bit.

  1. This one is cool. Try :
    a) select a component on a form in Delphi
    b) select Cut from the menu
    c) go to your favourite text editor
    d) select Paste
    e) you now have a textual representation of the component and its properties!
    f) change some of the properties, but be careful that your changes are legal
    g) select the whole text block again
    h) select Cut from the menu
    i) go to Delphi and select Paste
    j) the component now reappears with the changes you made!
  2. To place multiple instances of the same component on a form, hold down Shift and click on the component palette. Let go of Shift, then click on the form to place each instance of the component. Click on the arrow button when you are finished.
  3. Where's the Beep function ? Look up MessageBeep() in the Windows API online documentation.
  4. The options requestor from the Project Manager lists the forms of your project. It also allows you to drag them around to change the order of creation.
  5. .DFM files are binary, but can be loaded and viewed in the Delphi editor as readable text.
  6. Succ() and Pred() give you the next or previous value in an enumerated list.
  7. A form owns all event handlers of the components on it, and therefore the default scope is the form (i.e. in code, "Width" means "form.Width" even in a button's event-handler).
  8. The ampersand '&' in a Caption property causes the following character to be underlined (usually to indicate a shortcut key).
  9. For button bitmaps, the bottom left pixel's colour is used as the background key colour.
  10. To create the same event-handler for multiple controls, multi-select them and create an event-handler as normal.
  11. Speed buttons can work like radio buttons (i.e. allow only one of a group to be selected at a time).
  12. You can create constant arrays eg. :
    const array1 : array [0..1] of string = ('hello','Fred');
        
  13. Components can create instances of other components at run-time.
  14. Select a component on a form and try different combinations of shift, control and the arrow keys to select, move and resize.
  15. Borland Pascal allowed you to put initialisation code for a unit between a begin and the "end." at the end of the unit. This works in Delphi, but Delphi will put any new code between these two and cause syntax errors. The answer is to use initialization instead of begin.
  16. Empty event handlers get removed from the code when the project is compiled.
  17. Pascal doesn't have a power function (^ in C). Instead you can use a^b = Exp(b*Ln(a)).

Some I've learnt elsewhere :

  1. To make the mouse disappear, set the form.cursor to -1.
  2. ChartFX that comes with Delphi IS documented even though the F1 key won't help you. You have to search for "chart" in the help topic search.
  3. The form.Name property doesn't work. You can take form.ClassName and remove the leading 'T' if you don't have multiple instances of the same form.
  4. The online help for the OnCreate event lists order of events for creating a form in the wrong order. I don't know the correct order for sure, but its something like : OnCreate, OnShow, OnActivate, OnPaint. (OnShow and OnActivate may be reversed).

Enjoy !

Gary McGhee, gmcghee@yarrow.wt.com.au
® Delphi is a registered trademark of Borland International.
[ Home Page | What's New | About CITY ZOO | Borland Delphi | About the Authors | INDEX ]


gmcghee@yarrow.wt.com.au
Copyright © 1995 Gary McGhee. This is a CITY ZOO production.
Last revised September 4, 1995.