Question

We have TToolbarButton(s) on a toolbar, each with it's own associated TPopupMenu. The popup menus are all the same so we would like to have only one menus for all the toolbar buttons. The problem I have is determining which ToolbarButton invoked the popup menu.

I've tried the following, but I keep getting an access violation.

...

with (Sender as TPopupMenu) do
  ShowMessage((GetParentComponent as TPopupMenu).Name);

...

Any ideas how to get the parent of the popup menu?

Thanks, Pieter.

Was it helpful?

Solution

Try

  with (sender as  TPopupMenu)  do
      ShowMessage(PopupComponent.Name);

That should give you the TToolButton that was pressed.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top