Главная страница | назад





Article #16019: Intercepting the Ctrl-V key in a TMemo

 Question and Answer Database
FAQ1019D.txt Intercepting the Ctrl-V key in a TMemo
Category :VCL
Platform :All
Product :All 32 bit
Question:
How can I intercept the Ctrl-V key in a TMemo component and
paste custom text that is not currently on the clipboard?
Answer:
The following example demonstrates trapping the Ctrl-V key in a
TMemo component.
Example:
uses ClipBrd;
procedure TForm1.Memo1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if ((Key = ord('V')) and (ssCtrl in Shift)) then begin
if Clipboard.HasFormat(CF_TEXT) then
ClipBoard.Clear;
Memo1.SelText := 'Delphi is RAD!';
key := 0;
end;
end;
7/16/98 4:31:28 PM

Last Modified: 01-SEP-99