http://delphi.about.com/od/adptips2004/a/bltip0804_4.htm
Here's how to implement the code for the CTRL+A key combination ("Select All") for TMemo or TDBMemo:
~~~~~~~~~~~~~~~~~~~~~~~~~
Just drop a memo (Memo1:TMemo) on a form (Form1:TForm) and handle the OnKeyDown event for Memo1 as:
procedure TForm1.Memo1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState) ;
begin
if (Key = Ord('A')) and (ssCtrl in Shift) then
begin
TMemo(Sender).SelectAll;
Key := 0; //这里即使为0,Windows系统还是能继续接到按键的信息,然后就会导致 BEEP 声音(win7是当当的声音),因为这里只是 KeyDown。
end;
end;
~~~~~~~~~~~~~~~~~~~~~~~~~
Note: here's how to check the state of CTRL, ALT and SHIFT keys.
http://stackoverflow.com/questions/8466747/automatically-allowing-ctrla-to-select-all-in-a-tmemo
In Delphi 7's TMemo control, an attempt to do the key combo
Is there a trick so that I don't have to do this procedure? And if not, then does this procedure look OK? |
||||
This is more elegant:
|
|||||||||||||||||||||
|
TEdit
handles Ctrl+A as one would expect.) – Andreas Rejbrand Dec 11 '11 at 19:35