Einzelnen Beitrag anzeigen

nahpets
(Gast)

n/a Beiträge
 
#11

Re: Codes für KeyPress Ctrl shift delete Pfeil

  Alt 21. Jan 2009, 14:40
Hallo,

ist da nicht ein Denkfehler drin?
Delphi-Quellcode:
procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char);
begin
if key =#27 then caption:='esc'; // OK
if key = Ord('c') then caption:='Taste C'; // Passiert nichts
if key =#43 then caption:='Taste C'; // auch nichts
end;
Müsste es nicht etwa so aussehen?
Delphi-Quellcode:
procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char);
begin
  Case Key of
    #27 : caption := 'esc'; // OK
    'c'     : caption := 'Taste c'; // OK
    'C'     : caption := 'Taste C'; // OK
  end;
end;
Key ist bereits das Zeichen und muss nicht mit Ord "übersetzt" werden, bei KeyDown und KeyUp bekommt man jedoch Key als Word geliefert.
  Mit Zitat antworten Zitat