Using Lazarus components

From Free Pascal wiki

English (en)

Warning-icon.png

Warning: Tutorial under construction

What is a component?

A component is a Class - a module of code - typically comprising a data definition and a number of methods, which defines and describes a particular action or series of actions. Examples of components include buttons, labels, checkboxes, timers and dialogs.

Components vs Controls

While every control is a component, not every component is a control. Confused? Let's clear up the confusion: a control is a visual component that a user of your application can see and can interact with (control) using the keyboard and/or the mouse. For example, a TButton which you drop on a TForm is a visible component that a user can see and interact with using the keyboard and/or mouse. Visual components are typically user interface elements like buttons, labels, check boxes, radio buttons and dialogs.

On the other hand, there are components which have no visual control associated with them. For example, a TTimer which you drop on a TForm is a non-visual component. While you can see the TTimer at design time when you drop its icon on a form, there is nothing for the user to see or interact with at runtime.

Lazarus components

Lazarus comes with a number of useful components on its Component Palette. A list of the components can be found here. There are also additional components which can be downloaded separately from the Lazarus Code and Component Repository and installed.

There is also the Lazarus Online Package Manager which automates the downloading, installing and configuring of packages. Lazarus Packages are collections of units and components, containing information about how they can be compiled and how they can be used by projects or other packages or the IDE itself. The Online Package Manager can be found in the Lazarus IDE in the Package Menu.

Component properties

Component properties determine how the component appears and how it behaves. At design time, most properties have a sensible default, but you can alter them using the Object Inspector. You will most frequently need to edit the Caption and Name of components (eg forms, buttons and labels). When you edit the property in the Object Inspector, the visual appearance of the form or other component will be automatically updated by Lazarus.

Component events

t/c

See also