Why doesn't CTRL + C work with the TMemo component? (Vista + Delphi 7)

Why is it impossible to copy the selected text to the TDBMemo component to the clipboard? DELPHI 7, Windows Vista. The following code fails to catch ctrl + c event, while ctrl + a works fine.

uses clipbrd;

    procedure THierarchierForm.dbm1KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    begin

    if (Key=Ord('A')) and (ssCtrl IN Shift) then begin
    dbm1.SelectAll;
    Key:=0;
    end;

    if (Key=Ord('C')) and (ssCtrl IN Shift) then begin
    Clipboard.AsText:=dbm1.SelText;
    Key:=0;
    end;

    end;

Thanx

+3
source share
1 answer

The code you present works in the context of a simple vanilla form. There must be something else in the way.

Most obviously, your form has KeyPreviewset True, and therefore your form is processing CTRL+C.

Please note that I support my reservations expressed in the commentary on your question.

+3
source

Source: https://habr.com/ru/post/1790348/


All Articles