Why CTRL+C is not working on TMemo component? (Vista + Delphi 7)

2.2k views Asked by At

why it is not possible to copy selected text in TDBMemo component into clipboard? DELPHI 7, Windows Vista. Following code fails to catch ctrl+c event, whereas 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

1

There are 1 answers

2
David Heffernan On

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

The most obvious is that your form has KeyPreview set True and so your form handles CTRL+C.

Note that I stand by my reservations expressed in the comment to your question.