FMXTPopupMenu (C++)

From RAD Studio Code Examples
Jump to: navigation, search

Description

This example shows how to display a TPopupMenu component in the upper left corner of a TButton component, when left-clicking the button.

To test this example, create a Multi-Device Application - C++ Builder > Blank Application, and add the following objects on the form:


Add the following code for the OnClick event of the TButton component.

Code

void __fastcall TForm1::Button1Click(TObject *Sender) {

	TPointF FP;
	// Initialize the coordinates to the origin of the button control.
	FP.X = 0;
	FP.Y = 0;
	// Transposes the coordinates in the context of the form.
	FP = Button1->LocalToAbsolute(FP);
	// Transposes the coordinates in the context of the screen.
	FP = ClientToScreen(FP);
	// Display the popup menu at the computed coordinates.
	PopupMenu1->Popup(FP.X, FP.Y);
}

Uses

See Also