Friday, May 6, 2011

Determine Parent Component

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.

From stackoverflow
  • Try

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

    That should give you the TToolButton that was pressed.

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

0 comments:

Post a Comment