A: Here it is:
procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if button = mbRight then
WITH Sender AS TControl DO
WITH ClientToScreen(Point(X,Y)) DO
BEGIN
PopupMenu1.PopupComponent
:= TComponent(Sender);
PopupMenu1.Popup(X,Y);
END;
end;
Note: The form's popupMenu property must be empty, or it will
popup from everywhere. If you want the form to be the only place
showing the popup, place this method on the form's OnMouseDown event.
If you want the VBX to be the only place, then place it on the VBX's OnMouseDown
event, etc.