views:

197

answers:

1

Hi

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.

+5  A: 

Try

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

That should give you the TToolButton that was pressed.

Re0sless
Unfortunately PopupComponent.Name returns the Toolbar name and not the ToolbuttonName. It works ok on a ListBox. Pieter.
Pieter van Wyk