VCL.RelativePanel Sample

From RAD Studio Code Examples
Jump to: navigation, search

This is a sample that shows the use of the TRelativePanel control.

Location

You can find the RelativePanel sample project at:

  • Start | Programs | Embarcadero RAD Studio Sydney | Samples and then navigate to either:
    • Object Pascal\VCL\RelativePanel
    • CPP\VCL\RelativePanel
  • Subversion Repository:
    • You can find Delphi and C++ code samples in GitHub Repositories. Search by name into the samples repositories according to your RAD Studio version.

Description

This application demonstrates the TRelativePanel control and shows how to use the alignment properties of the child controls.

The application uses the following controls:

  • RelativePanel1: The relative panel.
  • pageControl1: A TPageControl with tabs for each of the controls on the relative panel.
    • TabSheet1, TabSheet2, TabSheet3 (Edit1, Button1, Shape1): The tabs of the pageControl1. Each contains the check boxes and drop-down menus that control the properties of the corresponding control on the relative panel.
      • cbAlignLeftWithPanel: Toggles the AlignLeftWithPanel property of the associated control.
      • cbAlignHorizontalCenterWithPanel: Toggles the AlignHorizontalCenterWithPanel property of the associated control.
      • cbAlignRightWithPanel: Toggles the AlignRightWithPanel property of the associated control.
      • cbAlignTopWithPanel: Toggles the AlignTopWithPanel property of the associated control.
      • cbAlignVerticalCenterWithPanel: Toggles the AlignVerticalCenterWithPanel property of the associated control.
      • cbAlignBottomWithPanel: Toggles the AlignBottomWithPanel property of the associated control.
      • cbxLeftOf: Allows you to modify the LeftOf property of the associated control.
      • cbxAlignLeftWith: Allows you to modify the AlignLeftWith property of the associated control.
      • cbxAlignHorizontalCenterWith: Allows you to modify the AlignHorizontalCenterWith property of the associated control.
      • cbxAlignRightWith: Allows you to modify the AlignRightWith property of the associated control.
      • cbxRightOf: Allows you to modify the RightOf property of the associated control.
      • cbxAbove: Allows you to modify the Above property of the associated control.
      • cbxAlignTopWith: Allows you to modify the AlignTopWith property of the associated control.
      • cbxAlignVerticalCenterWith: Allows you to modify the AlignVerticalCenterWith property of the associated control.
      • cbxAlignBottomWith: Allows you to modify the AlignBottomWith property of the associated control.
      • cbxBelow: Allows you to modify the Below property of the associated control.
  • cbxVclStyles: A combo box that allows you to change the style of the application. You can choose between any style that is active in the Application Appearance - Custom Styles options for this project.

How to Use the Sample

  1. Navigate to one of the locations given above and open:
    • Delphi: RelativePanel.dproj.
    • C++: RelativePanel.cbproj.
  2. Press F9 or choose Run > Run.
  3. Change the different alignment options for each control on the corresponding tab. Modify alignment of the controls relative to each other and to the relative panel.

Implementation

TRelativePanelForm

On initialization, the FormCreate adds all the active styles to the cbxVclStyles combo box.

The application defines the following event handlers:

  • RelativePanel1DragOver: Allows you to drag controls around the relative panel.
  • RelativePanel1DragDrop: Allows you to drop controls on the relative panel.
  • SampleControlMouseDown: Initiates a drag of the current control and changes the tab to the one associated with the current control.
  • cbAlignHorizontalCenterWithPanelClick: Toggles the AlignHorizontalCenterWithPanel property of the associated control.
  • cbAlignRightWithPanelClick: Toggles the AlignRightWithPanel property of the associated control.
  • cbAlignTopWithPanelClick: Toggles the AlignTopWithPanel property of the associated control.
  • cbAlignVerticalCenterWithPanelClick: Toggles the AlignVerticalCenterWithPanel property of the associated control.
  • cbAlignBottomWithPanelClick: Toggles the AlignBottomWithPanel property of the associated control.
  • cbxLeftOfChange: Allows you to modify the LeftOf property of the associated control.
  • cbxAlignLeftWithChange: Allows you to modify the AlignLeftWith property of the associated control.
  • cbxAlignHorizontalCenterWithChange: Allows you to modify the AlignHorizontalCenterWith property of the associated control.
  • cbxAlignRightWithChange: Allows you to modify the AlignRightWith property of the associated control.
  • cbxRightOfChange: Allows you to modify the RightOf property of the associated control.
  • cbxAboveChange: Allows you to modify the Above property of the associated control.
  • cbxAlignTopWithChange: Allows you to modify the AlignTopWith property of the associated control.
  • cbxAlignVerticalCenterWithChange: Allows you to modify the AlignVerticalCenterWith property of the associated control.
  • cbxAlignBottomWithChange: Allows you to modify the AlignBottomWith property of the associated control.
  • cbxBelowChange: Allows you to modify the Below property of the associated control.
  • cbxVclStylesChange: Sets the style for the application.

The application also defines the following public procedure:

  • SelectedControl: A helper method that forwards the actions of a check box or a drop-down menu to the corresponding control.

Uses

See Also