Wednesday, March 2, 2011

What did I just right click on?

Delphi makes it very easy to add context sensitive menus (or mostly known as popup menus that appear on right mouse clicks!) to your application:

  • Create a "New Application"
  • Drop a "TPopupMenu" component on your form
  • Double click on it and add necessary menu items
  • Select your form and set its "PopupMenu" property to the newly created "TPopupMenu" (named "PopupMenu1" by default)
  • Run your program to and right click on your form
That was easy enough. But, the question is, once you add more components to your form, how do you determine which control your user right clicked on?
Assuming that the name of your popup menu is "PopupMenu1," following will contain the name of the right clicked control:
NOTE: In order to get a valid control name, you must assign the popup menu to each control's "PopupMenu" property.

Source :

Twitter Delicious Facebook Digg Stumbleupon Favorites More

Design by Kang Iwan K-sev | Thank's for your visit To My Site - Ridwan Mulyana | Cibeureum