Главная страница | назад





Article #16078: Popup menu, which object invoked it?

 Question and Answer Database

FAQ1078C.txt   Popup menu, which object invoked it?
Category   :VCL
Platform    :All
Product    :C++Builder  1.x

Question:

How can the event handler of a popup menu item determine which
component was right-clicked upon to activate that menu?

Answer:

Use the TPopupMenu::PopupComponent property to determine what 
control the menu was activated for.

   void __fastcall TForm1.PopupItem1Click(TObject *Sender)
   {
      Label1->Caption = PopupMenu1->PopupComponent->ClassName();
   }

The form's ActiveControl property can also be used, however, 
the active control may not necessarily be the control that
caused the popup menu to appear. 

7/2/98 10:32:32 AM
 

Last Modified: 01-SEP-99