Form-based Applications
You can quickly add components to forms and produce impressive-looking applications. Rapid Application Development (RAD) depends on much previous work by developers to create visual components (controls) that will be used in a wide variety of applications. For example, the string grid and its ancestors in Lazarus required 11000 lines of source code in Grids.pas. You can use a string grid to display, load, save and edit records and to sort them by a string field. This may be exactly what you need for a prototype to discuss with your end user. However, if you rely on the code of others and write only a few lines of your own you will be unlikely to cope well in unfamiliar situations in the future. We advise you code your own versions of recognised sorting and searching algorithms and to base your database-type applications on arrays and files of records. You should be able to adapt our demonstration code for console programs to your form-based applications.
- using the Object Inspector;
- editing the text view of the form;
- writing code such as lblResult.Caption := 'You won!';
- (for positions and sizes of visual components) dragging the bounding rectangles in the design view of the form.
We usually prefix component names according to the convention given in this online coding standards page.
We concentrate on using the Lazarus IDE so that beginners can make progress without needing to buy Delphi. You will probably find that you can use many components intuitively, so we do not think it is worthwhile for us routinely to "double up" and demonstrate Delphi also. Follow these steps to try the Lazarus examples in Delphi:
- Omit from the uses section any units such as Interfaces that Delphi does not recognise;
- Change the compiler directive {$R *.lfm} to {$R *.dfm};
- Rename the Lazarus form files from *.lfm to *.dfm. You need to delete any lines that Delphi does not recognise, such as LCLVersion = '0.9.30';
- The new project file will have the extension .dpr instead of .lpr.
Some of the components that we use in demonstrations do not appear in the title of a section. Here is an alphabetic list of 53 components with a link to a section in which we use each one.
TADOTable, TBitBtn, TBufDataset, TButton, TCalendarDialog, TChart, TCheckBox, TColorDialog, TComboBox, TComboBoxEx, TDataSource, TDateTimePicker, TDBCalendar, TDBEdit, TDBDateEdit , TDBGrid,TDBImage, TDBNavigator, TDBText, TEdit, TFontDialog, TGeckoBrowser, TGroupBox, TImage, TImageList, TIpHtmlPanel, TLabel, TLabeledEdit, TListBox,TLvlGraphControl, TMapViewer, TMemDataset, TMemo, TMenu, TMenuItem, TMVGLGeoNames, TODBCConnection, TOpenDialog, TOpenGLControl, TPageControl, TPaintBox, TRadioGroup, TSaveDialog, TScrollBar, TShape, TSQLQuery, TSQLTransaction, TStaticText, TStringGrid, TSynEdit, TTimer, TTrackbar, TTreeView, TWebBrowserSince we wrote most of this tutorial Jerzy Griffiths contributed his professional-looking Delphi XE4 word processor. He uses a big range of components to good effect.
Follow the links below to the sections of the tutorial.