Several standard controls used in most Lazarus forms Determines the case of text displayed in the edit box or combobox. Normal mode - Character case according to what the user types. Converts every character that the user types into upper case characters. Converts every character that the user types into lower case characters. TEchoMode: Determines how strings in the edit box are displayed. The scroll action type. Scroll one line up. Scroll one line down. Scroll one page up. Scroll one page down. Scroll to the specified position. Scroll tracking to the specified position. Scroll to the top. Scroll to the bottom. Scroll ends. The scroll event. Determines the scroll action. Contains the current scroll position. TCustomScrollBar: the base class for TScrollBar TCustomScrollBar TCustomScrollBar Defines the Max and Min values, the size of the page and the position of the scroller Kind of scroll bar - whether Horizontal or Vertical LargeChange - the size of the step to be taken by the slider for a large change A LargeChange is produced by the user clicking on the blank area above or below the slider; it is rather analogous to the Page Down or Page Up functions of the Keyboard and is typically set up to move the slider and the contents of the page or canvas by a whole paragraph or half a page or a full page. The maximum value (for bottom of the scroll bar or the right-most extent) the minimum value, for the top of the scroll bar or its left-most extent PageSize: the size of a page - typically used for LargeChange The Position of the scroller along the ScrollBar SmallChange - the size of the step to be taken by the scroller for a small change A small change is produced by the user clicking on one of the triangular tags at either end of the scrollbar. It is rather analogous to the effect of using the up or down arrows on the keyboard, and is typically set to produce a movement of a few pixels or a single line of text Whether the scrollbar can be reached by use of the Tab key - default is True Event handler for any change in position of the slider or other mouse movement or keyboard event associated with the scrollbar OnScroll - Handler for a scrolling event (by mouse, keyboard or program)

OnScroll - Handler for a scrolling event

Called when there is any movement of the slider by mouse, arrow keys or Page Up/Down keys, or if the display in the main window is caused to scroll

TScrollBar - a control that allows the user to scroll the current page or document window by moving a slider

TScrollBar - a control that allows the user to scroll the current page or document window by moving a slider

It appears as a long rectangular track or bar within which a smaller contrasting block or slider can move up and down (or from side to side in a horizontal ScrollBar)

It has small triangular indicators or pointers at each end. Typically, for a vertical ScrollBar the top indicator points up, and at the bottom there is a pair of pointers, one up and one down. Clicking with the mouse on one of the pointers moves the slider a small distance (SmallChange) in the specified direction, and the programmer's responsibility is to ensure that the page, image or document in which the ScrollBar is found will scroll by a corresponding small amount

Clicking with the mouse in the blank area of the scrollbar above or below the slider makes the slider move by a larger increment (LargeChange) and scrolls the contents of the window by a larger amount - several lines, a paragraph, half a page or anything up to a page (PageSize)

The slider can also be moved by clicking on it with the mouse, and holding down the button while moving the mouse. The slider follows the mouse until the button is released. If the mouse has a scrollwheel, the slider can be similarly moved by rotating the wheel. In each case, the contents of the window scroll by a corresponding amount

Scrolling of the window and movement of the slider can also be achieved by using the directional arrows or the Page Up/Page Down keys on the keyboard

The location of the slider along the track is held in the Position property, which reports where the mouse has placed it, or can alternatively be set to an arbitrary location by the program. If the mouse or arrow keys are used to move the cursor somewhere on the main window so as to make the display scroll (eg by moving beyond the top or bottom line in a text display) the scroll bar slider moves to indicate the corresponding location along the scroll bar

TCustomGroupBox - the base class for TGroupBox, TRadioGroup and TCheckGroup Sets up default size for the class TGroupBox - a container that allows a number of objects to be grouped physically and conceptually on the form

Group Box. Allows a number of objects to be grouped physically and conceptually on the form; they can be moved around together and have certain properties in common.

Defines the behavior of the AutoComplete feature in a combobox control.

TComboBoxAutoCompleteTextOption defines the behavior of the AutoComplete feature.

  • cbactEnabled: Enable Auto-Completion feature.
  • cbactEndOfLineComplete: Perform Auto-Complete only when cursor is at the end of the string.
  • cbactRetainPrefixCase: Retains the case of characters user has typed. (This option has no effect if cbactEndOfLineComplete is False)
  • cbactSearchCaseSensitive: Search completion string with case sensitivity.
  • cbactSearchAscending: Search completion string in accending order. (False will search in descending order)
Set of TComboBoxAutoCompleteTextOption ComboBox Style ComboBox Style: may be Simple, a single-line Drop-Down or a Drop-Down list, or some version drawn by the Owner TCustomComboBox - the base class from which TComboBox is derived

TCustomComboBox - the base class from which TComboBox is derived

Despite similarities in appearance to TCustomEdit and TCustomList , the class inherits no properties from these classes, but only from TWinControl

It has some interesting properties including AutoComplete and AutoCompleteText, AutoDropDown and the ability to create and add a History display

FCharCase: TEditCharCase FAutoCompleteText: TComboBoxAutoCompleteText Private variable of property AutoCompleteText. Options for behavior of the Auto-Complete feature. FAutoSelect: Boolean

Private variable for property AutoSelect. When True, the edit control will select all its text when:

  • It receives focus
  • The Enter key is pressed.
  • A new item is selected.
FAutoSelected: Boolean Private variable for property AutoSelected. True indicate that the edit or combobox control has just performed an AutoSelect operation so that subsequent mouse-clicks and keystrokes proceed normally without selecting the text. False is set when the edit or combobox control loses focus. Combo Box DropDownCount - number of entries in the drop-down list ItemHeight - the height of the current item in the drop-down list ItemWidth - the width of the current item in the drop-down list MaxLength - the maximum allowed length of a string OnChange - event handler for any change in properties of the combo box OnCloseUp - event handler for when the drop-down box is closed up again OnDrawItem - event handler for when an entry is written to the Items list OnDropDown - event handler for when the drop-down list appears Sorted - whether the entries in the drop-down list have been sorted AddItem - adds an Item to the list in the drop-down box AddHistoryItem - Add an Item as first entry in History List

AddHistoryItem - Add an Item as first entry in History List

Removes the Item from old position and removes last item if history is full

Clear - remove all text and drop-down list ClearSelection - clear the currently selected text or items from drop-down list CharCase: indicates whether text is to be displayed as Upper, Lower or Normal case (as entered)

Indicates how text is displayed in a text editing control in the following ways:

  • Normal case letters
  • Upper case letters
  • Lower case letters
DroppedDown - indicates whether or not the drop-down list has appeared AutoComplete - enables the facility to offer suggestions for completing text-strings AutoCompleteText : Options for behavior of the Auto-Complete feature

AutoCompleteText: Options for behavior of the Auto-Complete feature

  • Enabled: Enable Auto-Completion feature.
  • EndOfLineComplete: Perform Auto-Complete only when cursor is at the end of the string.
  • RetainPrefixCase: Retains the case of characters user has typed. (This option has no effect if cbactEndOfLineComplete is False)
  • SearchCaseSensitive: Search completion string with case sensitivity.
  • cbactSearchAscending: Search completion string in accending order. (False will search in descending order)

This property exists as a Set of Options, so zero or more options may be operational

AutoDropDown - if True, the drop-down list appears as soon as the cursor moves over the text box

AutoDropDown - if True, the drop-down list appears as soon as the cursor moves over the text box

If False, the drop-down box only appears when the downward triangular indicator at the end of the box is selected

AutoSelect: Boolean. If True, all contents of Text box are selected when control receives focus

When True, the edit control will select all its text when:

  • It receives focus
  • The Enter key is pressed.
  • A new item is selected.
AutoSelected: True indicates that the combobox control has just performed an AutoSelect operation

True indicates that the combobox control has just performed an AutoSelect operation so that subsequent mouse-clicks and keystrokes proceed normally without selecting the text.

False is set when the combobox control loses focus.

ArrowKeysTraverseList - enables the operator to use the keyboard Arrow keys to move through the list as an alternative to using the mouse Canvas - the area on which the components are drawn or painted Items - an array of strings that holds the entries of the drop-down list Index - the number of the currently selected item (starting at zero)

Index - the number of the currently selected item

The first item has number 0, the second has number 1, the third number 2, etc.

In case no item is selected, ItemIndex has value -1.

ReadOnly - if True, information in the control can only be Read, not Written or Deleted SelLength - the length of the text that has been selected SelStart - the starting position of the text that has been selected SelText - the text string that has been selected for editing Style: may be Simple, a single-line Drop-Down or a Drop-Down list, or some version drawn by the Owner Text - the string appearing in the main box. If an item on the drop-down list is selected, it replaces the contents of Text TComboBox - a simple combination of text box for free text entry, and a drop-down list allowing one of several options to be chosen.

TComboBox - a simple combination of text box for free text entry, and a drop-down list allowing one of several options to be chosen.

The default text-string (if any, entered in the Form Designer) and the value of the text string that is ultimately selected from the drop-down list, is held in Text

The values that can be selected from the drop-down list are held in the string-array Items. Clicking on the ellipsis (...) next to Items in the Object Inspector opens a pop-up string-list editor which allows the designer to enter and edit a number of lines of text to represent the selections

At run-time, the entry selected from the drop-down list in Items is used to replace any information previously found in Text, and ItemIndex holds the (zero-origin) index number of the selected item

If no value is selected from the drop-down list, the default text (if any) remains, or any information typed directly into Text will be returned, and ItemIndex takes the value of -1

TCustomList Box: the base class for TListBox Canvas - defines the area on which all graphic material is drawn Columns - the number of vertical columns in which the Items are arranged Count - the number of entries in the list of Items ExtendedSelect - boolean. Whether extended selection is allowed. Default True ItemHeight - the height of the individual Items ItemIndex: Integer to indicate the currently selected item (zero origin) Indicates the currently selected item. The first item has number 0, the second has number 1, the third number 2, etc. In case no item is selected, ItemIndex has value -1. If MultiSelect is True, ItemIndex represents the item which has focus, which typically has a different color from the other items. Items - an array of strings representing the list of entries MultiSelect - allows more than one Item from the list to be selected at a time, by pressing the CTRL or SHIFT key while selecting OnDrawItem - event handler for drawing an Item

OnDrawItem - event handler for drawing an Item

For example, selecting an item may require it to be highlighted or have its font or background changed

OnMouseWheel - event handler for movement of the scroll-wheel on the mouse OnMouseWheelDown - event handler for downwards scrolling movement of the mouse wheel OnMouseWheelUp - event handler for upward scrolling movement of the mouse wheel OnSelectionChange - event handler for changing the Item selected Selected - whether the Item with given Index has been selected Sorted - whether the selected Items in the list have been arranged in alphabetical order Style of List Box - normal, owner-draw fixed, or owner-draw variable TListBox : a simple string list from which a choice is made

TListBox: a simple string list from which a choice is made

The array of strings is held in Items

Clicking on the ellipsis (...) next to the Items entry in the Object Inspector at design-time opens a string-list editor in which the individual text-strings for the list can be entered or edited. The editor also allows the entries to be sorted alphabetically in normal or reverse order.

TCustomEdit : the base type from which the TEdit Box is derived.

TCustomEdit : the base type from which the TEdit Box is derived.

This control deals, for example, with issues such as selection of text sub-strings within the whole text string which are to be edited (cut, pasted, deleted, highlighted etc)

FAutoSelect: Boolean

Private variable for property AutoSelect.

When True, the edit control will select all its text when:

  • It receives focus
  • The Enter key is pressed.
  • A new item is selected.
FAutoSelected: Boolean Private variable for property AutoSelected. True indicate that the edit or combobox control has just performed an AutoSelect opertation so that subsequent mouse-clicks and keystrokes proceds normally without selecting the text. False is set when the edit or combobox control loses focus. FCharCase: TEditCharCase

Private variable for property CharCase. Indicates how text is displayed in a text editing control.

  • Normal case letters
  • Upper case letters
  • Lower case letters
AutoSelect: if True, the edit control will select all its text when it receives focus or when the Enter key is pressed. AutoSelected: if True, indicates that the edit control has just performed an AutoSelect operation

If True, indicates that the edit control has just performed an AutoSelect operation so that subsequent mouse-clicks and keystrokes proceed normally without selecting the text.

False is set when the edit control loses focus.

Clear - delete all text SelectAll text, for example in order to copy or delete it ClearSelection - delete all characters in selected text CopyToClipboard - put a copy of the selection on the clipboard, while leaving the original text in place CutToClipboard - remove the selected text from its original location and put it on the clipboard PasteFromClipboard - put a copy of the clipboard contents at the current writing position TEditCharCase - rules for what case to use (upper or lower) to display text

Indicates how text is displayed in a text editing control in the following ways:

  • Normal case letters
  • Upper case letters
  • Lower case letters

The rules can, of course, be overridden by use of the shift key.

EchoMode - how to echo keypresses on screen: normal (returning the actual character for that key), all upper or lower case, or a masking character as used in entering passwords MaxLength: maximum length allowed for text string Modified Modified: has the text been modified since creation? OnChange - event handler for any change in text PasswordChar: the character which appears in the Edit box replacing and masking the actual character typed

PasswordChar: the character which appears in the Edit box replacing and masking the actual character typed.

Typically used in password input, to prevent the typed characters from being seen by passers-by or casual observers (or even malicious observers!)

ReadOnly - the contents of the edit box may only be read, not written or erased SelLength: the length (in characters) of the text that has been selected for editing Sel Start: the index of the character from which selection (for editing) begins Sel Text: the string within the edit control that has been selected for editing Text: the character string contained in the Edit Box Text: the character string contained in the Edit Box TMemoScrollBar - a Scroll Bar specifically for use in Memo Boxes Scroll Bar specifically for use in Memo Boxes. Inherits most of its properties from its ancestor, TControlScrollBar TCustomMemo: the base class for TMemo Create Create the Custom memo widget Destroy Destroy the CustomMemo widget when you have finished with it Append - procedure for adding a text string to the Memo Alignment - whether text is centered, left- or right-justified Lines : an array of strings (single lines of characters) which contains the text held or being entered in the Memo Lines: an array of strings (representing single lines of characters) which contains the textual material held or being entered in the Memo. The array is zero-indexed, ie the strings are numbered [0..numLines-1] Whether the Memo has ScrollBars - none, horizontal or vertical or both, or automatically placed if needed Is WordWrap enabled, allowing long words to be carried on to the next line? Word Wrap: a logical flag to show whether or not word-wrap is enabled, ie if a word is close to the end of a line and is going to be too long for the line, it is wrapped down to the next line TEdit - an Edit Box: for entry or display of a single line of text. Password Character Password Character - defines which character should appear in the edit box when a password is being typed. TMemo - a box for entry or display of multiple lines of text

TMemo - a box for entry or display of multiple lines of text.

The textual data is held as an array of strings in Lines, where it can be edited

Max Length Max Length: the maximum permitted length for the textual material in the memo Word Wrap Word Wrap: a logical flag to show whether or not word-wrap is enabled, ie if a word comes near the end of a line and is going to be too long for the line, it is wrapped down to the next line TCustomStaticText: the base class for Static Text Alignment - whether text is centered, left- or right-justified ShowAccelChar - underline the character in the static text that acts as an accelerator with a shortcut key

ShowAccelChar - underline the character in the static text that acts as an accelerator with a shortcut key

Boolean property - default True

TStaticText: a box to display a Constant Text String

TStaticText: a box to display a Constant Text String

Use this control to display a statement or comment that is not likely to change very often, or is not usually responsive to user actions

Align Align: Is used to align a Static Text box to a border of a parent control. Anchors Anchors: keep the edges of a static text box a defined distance from certain borders of the parent control. Caption Caption: the text that actually appears with the Static Text Box Constraints Constraints: Sets the minimum and maximum sizes for a control. On Click - Action On Click - Action to be taken when the mouse button is clicked with the cursor over this control. User-defined Procedure On Double-click - Action On Double-click - Action to be taken when the mouse button is double-clicked while the cursor is over the control. User-defined Procedure On Mouse Down - Action On Mouse Down - Action to be taken when the mouse button is down while the cursor is over this control. User-defined Procedure On Mouse Entry - Action On Mouse Entry - Action to be taken when the mouse cursor enters the bounds of this control. User-defined Procedure On Mouse Leaving - Action On Mouse Leaving - Action to be taken when the mouse cursor leaves the boundaries of this control. User-defined Procedure. On Mouse Movement - Action On Mouse Movement - Action to be taken if the mouse cursor moves within the bounds of this control. User-defined Procedure On Mouse Up - Action On Mouse Up - Action to be taken if the mouse button is up while the cursor is over this control. On Resize - Action On Resize - Action to be taken when the control is resized. Might include re-alignment of text or selection of a different font size etc. User-defined Procedure Visible Visible - determines whether or not the control can be seen TButtonControl: ancestor class for several Button (including Radio Button) and Check Box classes Click - the procedure which allows programmatic simulation of a mouse click

Click - the procedure which allows programmatic simulation of a mouse click, and thus activation of the Action associated with the OnClick event

Checked - whether this button has been checked, which signifies selection OnChange - event handler for any change in properties of the control TButtonControl TButtonActionLink - provides a link between a button and its corresponding action

TButtonActionLink - provides a link between a button and its corresponding action

This class provides very few properties of its own, but inherits a lot from its ancestors, TWinControlActionLink, TControlActionLink, TActionLink and TBasicActionLink

TCustomButton - the base class for TButton and TBitBtn Creates a new instance of the TCustomButton class If you drop a component on the form editor you don´t need to add code to explicitly create it. The component is automatically created together with the the form, and destroyed when the form is destroyed. Performs the action associated with the button if it is the Default button Performs the action associated with the button if it is a Cancel button or if 'Escape' was pressed Is this control Active - has it got Focus; is the mouse over it? Is this the Default button? (default setting is False)

Defines if a button is the Default on a form. That is, pressing ENTER will execute its onClick method, whether the control has focus or not!

Is a Modal Result awaited? (default is false) Is this the Cancel button? (default setting is False)

Setting this property to true, will have the effect that when the user hits ESC this button is Clicked, even if the button does not have focus. Usually the Button which reacts to ESC sets the ModalResult of the form to mrCancel.

What Colour is the button? (default is the same as all other button faces) Is the Button included in the TabStop list? (default setting is True) TButton: Base type for all Buttons. A push button control

TButton: Base type for all Buttons. A push button control.

The user pushes a button (eg selects it with the mouse cursor and clicks the mouse) to start an action.

Click, calling this method will invoke the OnClick event of the button If you want to programmatically Click on a button you can call its Click method. This will have the same effect as a user clicking on the button. Sets the text displayed on the button. Constraints can be used to give a control certain minimum and or maximum dimensions. Sets the minimum and maximum sizes for a control. If a control is resized the new dimensions are allways within the ranges given here. You should take care when setting these options that they do not conflict with the Anchors and Align settings. Font is used to set the font of the caption of the Button. Font is used to set the font of the caption of the Button. If the button gets clicked, the ModalResult of the form will be set to this value. Setting ModalResult of a button makes closing a form easy. The OnClick event is triggered when a user clicks on the button. It can also be invoked by calling the Click method. Check Box State Check Box State: a set of constants defining the possible states of a Check Box - The check box has no check mark, indicating that the user has not selected the option. The check box has a check mark in it, indicating that the user has selected the option. The check box has a check mark in it, but it is grayed. TCustomCheckBox is the ancestor of all check-box components.

TCustomCheckBox: The base (abstract) class from which the TCheckBox is derived.

Check boxes present the user with options that can be selected (checked) or deselected (unchecked).

Determines whether the check box can be in a "grayed" state.

If AllowGrayed is set to True, the check box has three possible states: checked, unchecked and grayed. If AllowGrayed is set to False, the check box has only two possible states: checked and unchecked.

Indicates whether the check box is checked (selected), unchecked (deselected) or grayed.

See TCheckBoxState for possible values of State.

Use the TabStop to allow or disallow access to the control using the Tab key. If the TabStop is True, the control is in the tab order. If TabStop is False, the control is not in the tab order and the user can't press the Tab key to move to the control. TCheckBox - a small box which can contain a check mark to indicate that it has been selected by a mouse click

TCheckBox: a small box which can contain a check mark to indicate that it has been selected by a mouse click. May be associated with a Caption that describes its function.

Checked - shows whether or not the box has been checked (ie selected) TToggle Box: a labelled box capable of being checked or unchecked

TToggle Box: a labelled box capable of being checked (when it becomes recessed) or unchecked (when it is raised).

The Application Programmer is responsible for ensuring that the OnClick event handler recognises the State of the box, takes the appropriate Action and places the State into the next appropriate value

TRadioButton : a button that works with other Radio Buttons in a mutually exclusive way - if one button is selected, none of the others in the group can be selected

TRadioButton: a button that works in conjunction with other Radio Buttons in a mutually exclusive manner - if one button of a group is selected, none of the others in that group can be selected.

The Application Programmer is responsible for ensuring that the OnClick event handler for each button has a unique Action, and that the Actions of the other (deselected and therefore inactive) buttons are turned off.

TRadioGroup behaves differently from a group of TRadioButton controls placed arbitrarily around a form.

In the case of TRadioButton, the mutual exclusivity is a feature that applies to any RadioButton anywhere in the Form, and the RadioButtons can be rearranged in any order or placed anywhere within the containing Form, while in TRadioGroup the exclusivity applies only to buttons within the Group, which are ordered strictly according to their ItemIndex within the Items stringlist.

TRadioButton is an entity in itself, with a number of additional properties, whereas the buttons within TRadioGroup are not separate entities, but rather are simply entries in a list of strings, each of which is associated with the on-screen image of a RadioButton.

The example shows the difference between the use of TRadioButton and TRadioGroup

TRadioGroup
TCustomLabel: the base type from which TLabel is derived. TCustomLabel: the base type from which TLabel is derived. Alignment - whether text is centered, left- or right-justified FocusControl - whether this control has focus Layout - How the Text is to be laid out in the text rectangle: at the Bottom, Centre or Top ShowAccelChar - underline the character in the label that acts as an accelerator with a shortcut key

ShowAccelChar - underline the character in the label that acts as an accelerator with a shortcut key

Boolean property - default True

Transparent - whether the viewer can see through the control. Default True WordWrap - whether a word is to be wrapped to the next line if the text is about to become too long for the width available

WordWrap - whether a word is to be wrapped to the next line if the text is about to become too long for the width available

Boolean property, default False

OptimalFill - boolean. If True, font size is adjusted for optimal fill of available space TLabel: a brief text label to be placed in the Form near any object that needs to be identified. How to use StdCtrls, ComCtrls or ExtCtrls

The Units StdCtrls, ComCtrls and ExtCtrls contain definitions and descriptions of many of the most commonly used controls for constructing Forms and other Objects in Lazarus Applications.

Many of the final target controls that the application developer wants to use, such as TButton, TMemo, TScrollBar etc, have a corresponding ancestor class such as TCustomButton, TCustomMemo or TCustomScrollBar. Several of the properties and methods relevant to the final target control are defined (and explained) more fully in the TCustomXXX class, and are inherited by the final target control.

If you drop a component on the form editor you don't need to add code explicitly to create it. The component is automatically created by the IDE together with the form, and destroyed when the form is destroyed.

However, if you create the component yourself by code don't forget to free it when it is no longer needed.

If you place a component on the Form Designer and look at the Object Inspector, you can observe the properties change as you move the component around.

For example, if you place a button (TButton) on the form, click on it to select it, then move it around the form with the mouse, you can watch the values of Top and Left change in the Object Inspector to reflect the new position. If you use the object's re-sizing bars to adjust its size, you can watch the Height and Width properties change as well.

On the other hand, by using the Object Inspector, you can select the value associated with a property such as height, and type in a new value; you can watch the size of the object on the form change to reflect the new value.

You can also explicitly change the properties of the object in code by typing (in the appropriate Implementation section of the Source editor), for example

Form1.Button1.Height := 48;

If you type this new value into the Source Editor and then look back at the Form Designer, you will see that the button on the Form has taken the new size. The new value will also be shown in the Object Inspector.

In summary, there are usually about three different ways to determine each property of an object:

  • by using the mouse,
  • by setting the values in the Object Inspector,
  • or explicitly by writing code.

The components defined in these Units have several properties that are common to most of them, and other properties that are specific to the individual components. We shall describe the most common ones here. Unusual or control-specific properties will be described for the individual controls.

Additional Help can always be obtained by selecting a property or keyword, in either the Object Inspector or the Source Editor, and pressing F1. You will be taken by your Help browser to the appropriate page in the documentation.

If the description of a property on that page is insufficient, you can navigate to the corresponding description in the ancestor classes, by selecting the links in the Inheritance listing or by selecting the ancestor Type in the declaration of the object.

Constructors such as Create allocate memory and system resources needed by the object. They also call the constructor of any sub-objects present in the class.

Destructors: remove the object and de-allocate memory and other resources. If you call Destroy for an object which hasn't being initialized yet it will generate an error. Always use the Free method to deallocate objects, because it checks whether an object's value is nil before invoking Destroy.

Take the following precautions when creating your own Destroy method:

  • Declare Destroy with the override directive, because it is a virtual method.
  • Always call 'inherited Destroy;' as the last thing on the destructor code.
  • Be aware that an exception may be raised on the constructor in case there is not enought memory to create an object, or something else goes wrong. If the exception is not handled inside the constructor, the object will be only partially built. In this case Destroy will be called when you weren't expecting it, so your destructor must check if the resources were really allocated before disposing of them.
  • Remember to call Free for all objects created on the constructor.
Some commonly listed properties
Property Meaning
Action The main action or event associated with the object. For example selecting an 'Exit' Button might cause the 'Close' action
Align Defines the way in which an object is to be lined up with the parent object. Possible values are alTop (placed at the top and using the full available width), alBottom, alLeft (placed at the left and using the full available height), alRight. alNone (place anywhere on parent control) or alClient (takes all available space next to controls aligned to top, bottom, left or right)
Anchor Used to keep a control a certain distance from the defined edges of a parent control, when the parent is resized. For example [akBottom, akRight] will keep the control a fixed distance from the bottom right corner.
AutoSelect When True, an editing control will select all its text when it receives focus or when the Enter key is pressed.
AutoSelected True indicate that the edit or combobox control has just performed an AutoSelect operation so that subsequent mouse-clicks and keystrokes proceed normally without selecting the text.
BorderSpacing The space around the edge between an Anchored control and its parent.
Caption The text that is displayed on or near the control; it should preferably give some clue as to the function of the control, or an instruction such as 'Close' or 'Execute'. By default Caption is set to be the same as the 'Name' property, and the application programmer should substitute meaningful text instead of the default values.
CharCase Indicates how text is displayed in a text editing control: Normal (retaining the case of the letters typed by the user), converted to uppercase, or converted to lowercase
Constraints Sets the minimum and maximum sizes for a control. If a control is resized the new dimensions are always within the ranges given here. You should take care when setting these options that they do not conflict with the Anchors and Align settings.
Color The Colour to be used to draw the control or to write the text it contains.
Enabled A Boolean property to determine whether or not a control is capable of being selected and performing an action. If it is not Enabled, it is often Grayed out on the Form.
Font The Font to be used for writing the text associated with the control - either the caption or label, or the text-strings contained within the control. The entry on the Object Inspector usually has a (+) box on the left, and selecting this box reveals further options such as character set, colour and size.
Hint A short piece of informative pop-up text that appears if the mouse-cursor hovers over the control.
Items The list of 'Things' that the object contains, such as a group of images, a series of lines of text, a number of actions in an actionlist, etc
Lines An array of strings, containing the textual data in controls with more than a single line of data, such as an Edit-Box or a Combo-Box. The array is zero-indexed, ie the lines are numbered [0..numLines-1]
Name The identifier by which the control is known in the program. The IDE gives it a default name based on the underlying type, for example successive instances of TBitButton would be named Form1.BitBitton1 and Form1.BitButton2; it is up to the application programmer to give them more meaningful names such as ExitButton or OKButton. By default the Name of the control is applied to the Caption for the control, but the text of the Caption may be changed separately.
PopUpMenu A window containing context-sensitive menu information that pops up when the right mouse button is clicked on the object.
Position (or Top, Left) Determines where the control is located on the parent form or window
ReadOnly Boolean property which, if True, signifies that the contents of the control can be read by the user or the calling routine, but cannot be written or changed.
ShowHint Allows a small window containing a context-sensitive Help or other description to be displayed when the mouse cursor 'hovers' over the control.
Size (or Height and Width) The dimensions of the control
Style The options available for Style depend upon the sort of Control being considered: for instance the Style may be defined by TFormStyle, TBorderStyle, TButtonStyle etc.
TabOrder Integer defining where in the sequence of tabs on the Form this control is to lie
TabStop Boolean property which if True places this control in the sequence of objects that the user can reach by successively pressing the Tab key
Text The String of Text that represents the actual data that this control contains. Applies particularly to Text, Memo and StringList types of object. Most of the editing operations (such as Select, Clear, Cut, Copy) are performed in this part of the object, which holds the actual string being edited. If the control contains more than a single line of text, for example TMemo or TComboBox, then the textual elements are arranged as an array of strings (zero-indexed, ie numbered from [0..numLines-1]) in Lines.
Visible If true, the object can be seen on the Form; if False, object is hidden
WordWrap Logical flag to show whether or not word-wrap is enabled, ie if a word comes close to the end of a line and is going to be too long for the line, it is wrapped down to the next line.

Many actions are commonly listed in the 'Events' tab of the Object Inspector. If you select an entry in the list, a ComboBox appears with a DropDown list showing any actions that have aleady been defined, and allowing you to choose one to be associated with this event. Alternatively you can select the ellipsis (three dots ...) and you will be taken to an area of the Source Editor where you can begin typing your own action instructions for the selected event.

While a large number of events is available for any given control, in practice it is only necessary to populate a few of them. For most controls, it is sufficient to provide coding for 'OnClick'; for more complex controls it may be necessary also to provide for 'OnEntry' (when the mouse cursor enters the Control and gives it focus) and 'OnExit' (when the mouse cursor leaves the Control; or you may need to write an event handler for 'OnChange' or 'OnScroll', depending on the nature of the particular control with which you are dealing.

The pop-up menu that appears when you right-click an object in the Form Designer has, as its first item: 'Create default event' and selecting this option will have the same effect as selecting the ellipsis in the Object Inspector for the default event, usually OnClick: you are taken to the Implementation area of the Source Editor where you can type the code for the event handler.

A common strategy in Object-Oriented programming is to provide an ActionList with the facility for entering, removing or editing a number of pre-defined actions from which the most appropriate can be selected to use in any particular instance.

Some commonly listed Actions
Action Meaning
OnChange Action to be taken if any change is detected (eg mouse move, mouse click, key press, edit text, alter picture, etc)
OnClick Action to be taken when the (left) mouse button is clicked. This is usually the main or default action of the control; for example clicking on a button or checkbox initiates the action associated with the checkbox. It may alternatively initate a process of selection, for instance in a TextBox or Memo, or signal the beginning of painting with a Pen or Brush.
Click A method to emulate in code the effect of clicking on a control. This method is most often found in Button-type controls (TButton, TBitBtn, TSpeedButton etc). A procedure can be written that calls the same code as the OnClick action. This facility can be particularly useful if the activation of one control by clicking causes a cascade of other controls to be activated, and the Click method can be used to initiate the action rather than having the user explicitly click on a lot of controls.
OnDragDrop Action to be taken during Drag-Drop manoeuvres, ie when the mouse is used to 'capture' an item or some text etc and move it around the screen to a new location.
OnEntry Action to be taken when the mouse cursor enters the area occupied by the object, usually transfering focus to that object. This might include changes in the appearance of the object such as highlighting or raising the border.
OnExit Action to be taken when the mouse moves out of the area of the object, usually transferring focus out of the object.
OnKeyPress Action to be taken for any key-press. Subtly different from OnKeyDown, which simply responds to a key being down, whether or not it was already down when focus was given to this control. OnKeyPress requires that a key becomes pressed while focus is in this control.
OnKeyDown Action to be taken if a key is down while focus is in this control. Subtly different from OnKeyPress - for example the key might already have been down when focus entered this control, whereas OnKeyPress requires the key to become pressed while focus is in the control.
On Key Up Action to be taken if a key is up (ie not pressed) while focus is in this control.
OnMouseMove On Mouse Down - Action to be taken if the mouse cursor moves while focus is in this control.
OnMouseDown Action to be taken if the mouse button is down while focus is in this control.
OnMouseUp Action to be taken if the mouse button is up while the cursor is over this control. Implies that the mouse button was previously down and has been released. The case where the cursor enters the control but the mouse button has not yet been pressed is covered by OnEntry or OnMouseEnter.
OnResize Action to be taken when the control is resized. Might include re-alignment of text or selection of a different font size etc.