Autor Beitrag
FatalError
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 64

WIN ME
D6 Pers
BeitragVerfasst: Mo 29.12.03 18:47 
Hi,

wo liegt hier der Fehler? In einem anderen Thread stand, man müsste die Tastencodes von Strings in Typen umwandeln, aber wie muss ich das hier einfügen?

Grüße
Andy :)


ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char);
begin
   if key = 'VK_RETURN' then showmessage('ja');
end;
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Mo 29.12.03 18:55 
Hallo!

Der Unterschied zwischen String und Char ist Dir klar, oder? Denn in Deinem Code vergleichst den Char "Key" mit dem String 'vk_return'.

Die ganzen "VK_..."s sind alles Zahlen. Du musst es also so machen:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char);
begin
   if Ord(key) = VK_RETURN then showmessage('ja');
end;


MfG
Peter

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
FatalError Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 64

WIN ME
D6 Pers
BeitragVerfasst: Mo 29.12.03 22:06 
Hi,

ja, der UNterschied war mir klar, wusste aber nicht wie richtig machen :roll:

jetzt weiß ichs danke dir :D :lol:
Grüße
Andy
:D
FatalError Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 64

WIN ME
D6 Pers
BeitragVerfasst: Di 30.12.03 00:01 
Hi,

wie kann man auf die Pfeiltasten reagieren? Die Codes aus den FAQ bei "...lauten die virtuellen Tastencodes?" werden nicht als fehler angezeigt, werden aber nicht erkannt!?

Gruß
Andy :D
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Di 30.12.03 00:19 
Hallo!

Das liegt daran, dass die Cursortasten gar kein KeyPress-Ereignis auslösen, sondern nur ein KeyUp- und KeyDown-Ereignis. Und in einem von diesen Ereignissen musst Du sie dann auch bearbeiten.

MfG
Peter

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".