- - * - WhiteUnicorn - * - -




* #WhiteUnicorn/ StartPage/ Documentation/DelphiFAQ >


Frequently Asked Questions

Intercepting the Ctrl-V key in a TMemo

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;



* #WhiteUnicorn/ StartPage/ Documentation/DelphiFAQ >



- - * - Anastasija aka WhiteUnicorn - * - - LJLiveJournal
PFPhotoFile