FMXTStyleManager (C++)

From RAD Studio Code Examples
Jump to: navigation, search

Description

This example shows how to use the TStyleManager.SetStyleFromFile method in order to set the style of the form at run time.

To build and test this example create a new Multi-Device Application and add the following code to the OnCreate event handler of the form.

Note: You can also set the style of a form at design time, using a style book component.

Code

void __fastcall TForm1::FormCreate(TObject *Sender) {
	TOpenDialog *OpenDialog = NULL;
	try {
		OpenDialog = new TOpenDialog(this);
		OpenDialog->Filter = "Style Files|*.style";
		// Use a filter to show only the style files.
		if ((OpenDialog->Execute() == true))
		{ // Show the dialog and if the user clicked OK,
			TStyleManager::SetStyleFromFile(OpenDialog->FileName);
			// load the selected style and set it as the active style.
		}
	}
	__finally {
		OpenDialog->Free();
	}
}

Uses

See Also