Delphi Index


Updates

Delphi 5.01 update - 2-16-00 26 Meg

Free updated help files can be downloaded from Borland/Inprise. (For Delphi 2 and 4.)


Shortcuts / IDE

Use Ctrl-Space to list available components and variables (part of code completion). Be sure to read Code Insite / About Code Insite in the help.

Use Ctrl-Shift-Space to list the types of properties that a method expects.

When creating components, Ctrl+Shift+C helps to complete a class. (See Class completion in the help.)

Warning:

If a property is defined as write-only, Ctrl+Shift+C will automatically add a read directive AFTER the write directive. However, since the compiler requires the read directive to be BEFORE the write directive, you will get a error the next time you compile. This is annoying, but at least it throws a warning so that you can delete the reads you really don't want ... assuming you know that this is what is happening.

Use Ctrl-J to display the list of defined code templates.

Use Ctrl-Shift-UpArrow (or Ctrl-Shift-DownArrow) to toggle between the implementation and interface sections. For example, place the mouse cursor on a method prototype in the class definition and press Ctrl-Shift-UpArrow to see the code that implements that method.

Use Ctrl-UpArrow and Ctrl-DownArrow to scroll your code. Sometimes, this is easier than using the mouse and scroll bar.

List of keyboard shortcuts


Colors

You can use colors to help you find typing errors. For instance, select Tools / Editor Options... / Color and set


Units

code is saved in units (*.pas)

In order to re-name a unit, you must change the filename AND change the name in the first line of the file

and make the associated changes to *.dpr (the project file).

The easiest way to do this is to use File / Save As. However, it leaves the old copy of your files on the drive.

Files related to a unit - pas (code in ASCII), dfm (form), dcu (Delphi Compiled Unit)


The "uses" Clause

All Delphi programs contain a uses clause similar to On my system, each of these has a dcu (Delphi compiled unit) file in

When you write your own component, you include it by adding the name of the dcu file to the uses classes. Then you have to tell Delphi where to find it. From the menu, select

and edit Search Path as appropriate. (I don't suggest placing your dcu's in Delphi5\Lib. Use your own directory.)

The other technique is to place your components in packages and install them.


Setting Font Colors

The only edit field which allows font colors to be set on a per character basis is RichEdit.
  UIRichEdit.SelAttributes.color := clGreen;
It is also possible to paint directly to any component based on TCanvas.
  Canvas.TextOut(20, 20, 'Output Text');  


ScrollBar Control

ScrollBar1.Max := 1000;
ScrollBar1.Min := 500;
ScrollBar1.Position := 750;


Component Reference

Screen.ActiveControl.xxx


Misc

inc(i); vs i:=i+1; // inc() should be faster
Clipbrd.dcu    8 Kb
Windows.dcu  320 Kb
Messages.dcu  19 Kb
Classes.dcu   81 Kb
Graphics.dcu  64 Kb
Copy to Clipboard
Button on Form157 K
With Windows.pas14 K
With Wins.pas14 K
With Clipbrd.pas165 K

When opening the exact same source files on two different machines, I noticed that the size of the form with respect to the components on it was significantly different.


Design Problems

Using a TSpeedButton, there is a problem with the right mouse button. I have code that processes a mouse down and a mouse up. The mouse down executes fine. However, the mouse up executes only if the mouse is still over the TSpeedButton. Otherwise, it calls the mouse up associated with what ever control the mouse is over.

This does not happen when the left button is pressed, just with the right button. With the left mouse button, it does not matter where the mouse is pointing when the button is released, it still calls the mouse up event for the same control where the mouse down was called.

From Buttons.pas

 When the left button is pressed, the following are set
    FState := bsDown;
    FDragging := True;
Without re-writing the control, there is no way to set these 2 parameters when the right mouse button is pressed.

Since MouseDown calls Inherited MouseDown, which calls OnMouseDown, I even tried modifying the passed Button parameter - no effect. It appears to be passed by value, not by reference (ie, the value is placed on the stack, not the address).


References


Author: Robert Clemenzi
URL: http:// mc-computing.com / Languages / Delphi / index.html