FMX.Forms Sample

From RAD Studio Code Examples
Jump to: navigation, search

This is a project that shows how to display different forms depending on the orientation, portrait or landscape, of the device running your application.

Location

You can find the Forms sample project at:

Description

When you run the application, it shows a form with a background image and a label which states the current orientation of the device, either "Portrait" or "Landscape". When you change the orientation of your device, the form changes to display a different background image and updates the label to mach the new device orientation.

How to Use the Sample

  1. Navigate to the one of the locations given above, and open:
    • Delphi: Forms.dproj
    • C++: Forms.cbproj
  2. Press F9 or choose Run > Run.

Implementation

This application is composed of two forms, each one intended to be displayed when the target mobile device is in a specific orientation.

To show the right form for each orientation, this application handles the OnResize event of each form. The application uses these event handlers to show the right form depending on the Height and Width properties of the form: If Height is lower than Width, then it shows the landscape form, otherwise it shows the portrait form.

Uses

See Also