VCL.Frames Sample

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

Language:

Contents

This sample demonstrates how to use frames and the TSplitter class to create separate windows on the same form.

Location

You can find the Frames sample project at:

Description

The application creates a form with two frames: one that displays fish facts and another that displays customer and order information. Each frame is divided between resizeable controls using the TSplitter class.

The fish facts frame contains a grid with a list of all available fish species. Clicking a line in the grid displays a short description and an image for the selected species.

The customers and orders frame contains two resizeable grids also separated by a TSplitter object. When clicking a customer in the left grid, the corresponding order details are displayed in the right grid.

The data is retrieved from biolife.cds and customers.cds. Both files are shipped with the product.

How to Use the Sample

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

Files

The project has four source files:

File Contains

FrmFancy

The class for the frame that displays only the description and image for a selected row in the grid.

FrmData

The class for the basic frame used to display data retrieved from a *.cds file.

FrmMD

The class for a complex frame that consists of a master frame and a details frame.

FrmMain

The class for the main form.

Classes

  • TFancyFrame represents a frame that displays a description and an image for a selected row in the grid. It contains a TDBMemo and a TDBImage component. It is a part of TDataFrame.
  • TDataFrame represents a basic frame for displaying data. It contains TDBGrid, a TDBNavigator, and a TFancyFrame as visual components. It also contains nonvisual components, TDataSource and TClientDataSet, to retrieve data from *.cds files.
  • TMasterDetailFrame represents a complex frame composed of two TDataFrame. Select a row in the master frame on the left to see its details in the detail frame on the right.
  • TForm1 represents the main form. It contains a TDataFrame and a TMasterDetailsFrame separated by a TSplitter. TForm1 provides code to populate the grids with data from the *.cds file and to link the visual components to the data source and dataset.

Implementation

  • The TDBMemo and TDBImage components are linked at run time to the DataSource and to the corresponding fields of the dataset, in the main form’s OnCreate event handler. You can also use the object inspector to do this linkage at design time.
  • The information for customers and orders are displayed in a TMasterDetailFrame, from which the TFancyFrame components are freed at run time, in the main form's OnCreate event handler.

Uses

See Also

Personal tools
Previous Versions