1. Home
  2. Computing & Technology
  3. Delphi Programming

How to Disable TEdit's Default PopUp (Context) Menu

By Zarko Gajic, About.com

Disable Context Menu

When a user right-clicks on an Edit component at run time (or any other component that allows editing such as MaskEdit, Memo, DbEdit, etc.), by default the system's context menu pops up with options to undo, copy, paste, etc.

One way to get rid of this default popup menu is to assign a "dummy" empty popup menu to the PopUpMenu property of a TWinControl descendant (TEdit, TMemo, etc.)

Another way is to simply handle the OnContextPopup event by setting the Handled parameter to True.

The OnContextPopup gets fired when the user right-clicks the control or otherwise invokes the popup menu (such as using the keyboard - pressing SHIFT+F10 or the Application key).

Here's how the OnContextPopup implementation (to "disable" the context popup menu) looks like for the Edit1 (TEdit) component:

procedure TForm1.Edit1ContextPopup(
   Sender: TObject;
   MousePos: TPoint;
   var Handled: Boolean) ;
begin
   //disable default context popup
   Handled := True;
end;

Delphi tips navigator:
» How to Re-Initialize an Object to its Default State
« Programmatically Get and Set the State of the CapsLock and NumLock Keys

More Delphi Programming Quick Tips

Explore Delphi Programming

More from About.com

  1. Home
  2. Computing & Technology
  3. Delphi Programming
  4. Using VCL Components
  5. TEdit, TMaskEdit
  6. How to Disable the Default PopUp (Context) Menu for a TEdit Delphi component

©2008 About.com, a part of The New York Times Company.

All rights reserved.