This sample demonstrates how to use frames and the TSplitter class to create separate windows on the same form.
You can find the Frames sample project at:
- Start > Programs > Embarcadero RAD Studio > Samples and then navigate to either:
- Subversion Repository for Delphi: http://radstudiodemos.svn.sourceforge.net/viewvc/radstudiodemos/branches/RadStudio_XE2/Delphi/VCL/Frames/
- Subversion Repository for C++: http://radstudiodemos.svn.sourceforge.net/viewvc/radstudiodemos/branches/RadStudio_XE2/CPP/VCL/Frames/
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
- Navigate to Start > Programs > Embarcadero RAD Studio > Samples and open framesdemo.dproj.
- Press F9 or choose Run > Run.
The project has four source files:
The class for the frame that displays only the description and image for a selected row in the grid.
The class for the basic frame used to display data retrieved from a *.cds file.
The class for a complex frame that consists of a master frame and a details frame.
The class for the main form.
- 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.
- 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.