|
Using popup menu
TFormDesigner disables all the popup menus of all edited controls and the popup menu of the form when component is active, but you can use your own popup menu that can be used by the PopupMenu property of TFormDesigner. If this property is assigned, the popup menu is shown when the user clicks the right mouse button over the edited control. The contents of the menu can be edited using OnPopup event of the popup menu and the read-only MenuControl property of TFormDesigner. The MenuControl property contains the control, clicked by right mouse button. The code below shows/hides the menu items depending the type of control from the MenuControl property.
procedure TForm1.PopupMenu1Popup(Sender: TObject);
begin
with (Sender as TPopupMenu),FormDesigner1 do
begin
EditButtonMenuItem.Visible:=MenuControl is TButton;
EditLabelMenuItem.Visible:=MenuControl is TLabel;
end;
end;
|