0

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.

Pieter van Wyk
  • 2,316
  • 9
  • 48
  • 65
  • Menus don't have parents. You ay want the component *associated* with the menu, but there's no parent-child relationship involved. – Rob Kennedy May 09 '09 at 14:53

1 Answers1

6

Try

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

That should give you the TToolButton that was pressed.

Re0sless
  • 10,678
  • 6
  • 51
  • 66