RTL.ConvertIt Sample

From RAD Studio XE2 Code Examples
Jump to: navigation, search

Language:

Contents

This sample demonstrates how to perform conversions from one measurement unit to another.

Location

You can find the ConvertIt sample project at:

Description

This application creates a form with tabs for all registered conversion families: area, volume, temperature, and so on. For each conversion family, all the available units of measurement are displayed in the list box on the left. The user chooses a unit of measurement, specifies a quantity in the edit box, and the conversion results are displayed in the list box on the right of the form.

How to Use the Sample

  1. Navigate to Start > Programs > Embarcadero RAD Studio > Samples and open ConvertIt.dproj.
  2. Press F9 or choose Run > Run.

Files

File Contains

EuroConv

The code for registering the Euro conversion class.

ConvertItUnit

The code for the main form.

Classes

  • TConvTypeEuroFactor is the conversion class used to convert currency to and from Euro. For more information, see Using a Class to Manage Conversions.
  • TForm1 is the class for the main form of the application. It handles the display of the conversion families and types at run time and the conversion results.

Implementation

  • The conversion families tabs are added to the tab control component at run time in the OnShow event handler of the form. Likewise, the types for each family are added at run time in the OnChange event handler of the TTabControl component.
  • The registered conversion families and types are retrieved with the GetConvFamilies and GetConvTypes functions, respectively.
  • A TSpinEdit-like component is simulated by linking a TEdit and a TUpDown together using the TUpDown.Associate property.
  • The TEdit component has an OnChange event handler attached, so that the values in the results list box change as the user types in a value.

Uses

See Also

Personal tools
Previous Versions