If for any reason we don't want this menu to be displayed, one way is to simply put a TPopupMenu component on the form and assign it to the PopupMenu property of the components whose context menu we want to disable.
Here's a procedure that uses the RTTI and disables the popup of all controls on a container.
Uses TypInfo;
procedure DisablePopUp(AControl: TWinControl) ;
var
j : integer;
pm : TPopupMenu;
begin
pm := TPopupMenu.Create(AControl) ;
for j := 0 to AControl.ControlCount-1 do
if IsPublishedProp(AControl.Controls[j],'PopupMenu') then
SetObjectProp(AControl.Controls[j],'PopupMenu',pm) ;
end;
Usage:
DisablePopUp(Form1) ;
or
DisablePopUp(Panel1) ;
Another idea is to handle the OnContextPopup event
Delphi tips navigator:
» How to change the background color on different lines of text in a TListBox
« Creating a TString object


