Autor Beitrag
Bergmann89
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1742
Erhaltene Danke: 72

Win7 x64, Ubuntu 11.10
Delphi 7 Personal, Lazarus/FPC 2.2.4, C, C++, C# (Visual Studio 2010), PHP, Java (Netbeans, Eclipse)
BeitragVerfasst: Mi 15.03.06 19:36 
HI Leute,

ich hab folgendes Problem:
Ich will mir Snake programieren, nur so aus
langer Weile und um meinen Horizont zu erweitern.
Ich finde aber keine Prozedure oder eine Funktion
die auf das drücken, bzw. das gedrückthalten der
Arrow-Key anspringt. :?: Wäre nett wenn mir da
jemand helfen könnte.

MfG & THX Bergmann.

P.S. Ich benutz Delphi 7!
Stoney
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 122

Mac OS X 10.6 "Snow Leopard", Ubuntu Linux 9.04, Mandriva 2010, Win 7, Win Vista, Win XP
Object Pascal (Turbo Delphi, FPC 2.2.4, Lazarus), C++ (Code::Blocks, XCode), Java (Eclipse)
BeitragVerfasst: Mi 15.03.06 19:58 
Such mal in der Delphi-Hilfe nach den virtuellen Tastencodes. Da wirst du fündig.

So wird es integriert:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
// Für das Drücken bzw. Gedrückthalten die Tasten im OnKeyDown-Event eintragen.
procedure TForm1.OnKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if Key = VK_UP then // Nach oben;
  if Key = VK_DOWN then // Nach unten;
  if Key = VK_LEFT then // Nach links;
  if Key = VK_RIGHT then // Nach rechts;
end;
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Mi 15.03.06 20:00 
Und ich schätze mit OnKeyUp kannst du auf das Loslassen der Taste reagieren.

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Bergmann89 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1742
Erhaltene Danke: 72

Win7 x64, Ubuntu 11.10
Delphi 7 Personal, Lazarus/FPC 2.2.4, C, C++, C# (Visual Studio 2010), PHP, Java (Netbeans, Eclipse)
BeitragVerfasst: Mi 15.03.06 20:19 
Ja Danke für deine Zeit, das hab ich in der Hilfe
schon gefunden, ich weiß boß nicht wie das geht :
"Für das Drücken bzw. Gedrückthalten die Tasten
im OnKeyDown-Event eintragen." Dazu hab ich zwar
auch was gefunden aber das will nicht gehen.
wäre nett wenn du ma den ganzen Quelltext posten
oder Uploaden könntest.

THX Bergmann89.
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Mi 15.03.06 20:23 
Mein Posting war quatsch :oops:
Zum Demonstrieren:
Du setzt dir ein Memo aufs Formular, setzt enabled auf false und startest.
ausblenden Delphi-Quelltext
1:
2:
//OnKeyDOwn des Formulars
if Key = VK_UP then memo1.lines.add('Cursortaste oben gedrückt');

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Bergmann89 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1742
Erhaltene Danke: 72

Win7 x64, Ubuntu 11.10
Delphi 7 Personal, Lazarus/FPC 2.2.4, C, C++, C# (Visual Studio 2010), PHP, Java (Netbeans, Eclipse)
BeitragVerfasst: Mi 15.03.06 20:53 
Danke.
Jetzt bin ich schonma weiter, es kommt kein Fehler mehr wenn ich starte,
aber wenn ich jetzt die Tasten drücke bleibt das Memo wie es ist, es kommt nicht
die Zeile die ich im Quelltext eingegeben hab.

Kann mir da ma bitte noch schnell jemand helfen,
ich wil das heute noch fertig machen eh ih dann ins Bett hüpf.

Bergmann89.
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Mi 15.03.06 20:56 
Wenn ich das so mache und die Cursor-Taste oben gedrückt halte, dann erscheinen nacheinander neue Einträge im Memo :roll:

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Mi 15.03.06 20:58 
Büdde :wink:
Einloggen, um Attachments anzusehen!
_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Bergmann89 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1742
Erhaltene Danke: 72

Win7 x64, Ubuntu 11.10
Delphi 7 Personal, Lazarus/FPC 2.2.4, C, C++, C# (Visual Studio 2010), PHP, Java (Netbeans, Eclipse)
BeitragVerfasst: Mi 15.03.06 21:17 
Ich hab alles genau so gemacht wie du,
es geht immer noch nicht. Ich hab sogar den
kopletten Quelltext kopiert. Ich hab das ma
rangehängt, kannst ja ma bei dir probieren !
Einloggen, um Attachments anzusehen!
Stoney
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 122

Mac OS X 10.6 "Snow Leopard", Ubuntu Linux 9.04, Mandriva 2010, Win 7, Win Vista, Win XP
Object Pascal (Turbo Delphi, FPC 2.2.4, Lazarus), C++ (Code::Blocks, XCode), Java (Eclipse)
BeitragVerfasst: Mi 15.03.06 22:11 
Dein Fehler ist es, dass TForm1.FormKeyDown nicht mit der Form verknüpft worden ist.
Schau in den Objektinspektor, wähle den Registerreiter "Methoden" aus, schau dort auf das Ereignis OnKeyDown und wähle daneben im Pulldownmenü FormKeyDown aus.
Und es funktionniert (gerade ausprobiert).
Bergmann89 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1742
Erhaltene Danke: 72

Win7 x64, Ubuntu 11.10
Delphi 7 Personal, Lazarus/FPC 2.2.4, C, C++, C# (Visual Studio 2010), PHP, Java (Netbeans, Eclipse)
BeitragVerfasst: Mi 15.03.06 22:22 
Ja, schön dumm, darauf hätte ich auch selber kommen müssen.
Sorry für den Stress :oops: .

THX & MfG Bergmann89.