This is a project that shows how to display different forms depending on the orientation, portrait or landscape, of the device running your application.
You can find the Forms project at:
- Start | Programs | Embarcadero RAD Studio XE8 | Samples and then navigate to either:
Object Pascal\Mobile Samples\User Interface\Forms
CPP\Mobile Samples\User Interface\Forms
- Subversion Repository for Delphi: http://sourceforge.net/p/radstudiodemos/code/HEAD/tree/branches/RadStudio_XE8/Object%20Pascal/Mobile%20Samples/User%20Interface/Forms
- Subversion Repository for C++: http://sourceforge.net/p/radstudiodemos/code/HEAD/tree/branches/RadStudio_XE8/CPP/Mobile%20Samples/User%20Interface/Forms
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
- Navigate to the one of the locations given above, and open:
- Delphi: Forms.dproj
- C++: Forms.cbproj
- Press F9 or choose Run > Run.
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.