Autor Beitrag
Zlatan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 175



BeitragVerfasst: Di 25.01.11 15:12 
Wie kann ich mit Hilfe der Pfeiltasten einen einfachen punkt bewegen?
Also sodass ich bei Programmstart eine Punkt mit den Pfeiltasten bewegen kann.

Der Punkt kann z.B. ein Shape sein, oder? :?:


Moderiert von user profile iconMartok: Topic aus Sonstiges (Delphi) verschoben am Di 25.01.2011 um 14:35
MaxWurzel
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 77
Erhaltene Danke: 10



BeitragVerfasst: Di 25.01.11 15:38 
z.B. so:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  case key of
    VK_Left: shape1.Left := shape1.Left -1;
    VK_Right: shape1.Left := shape1.Left +1;
  end;
end;

Für diesen Beitrag haben gedankt: Zlatan
Zlatan Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 175



BeitragVerfasst: Di 25.01.11 15:56 
und was ist mit hoch und runter

Der Text scheint sehr fehlerhaft zu sein z.B. ist das var.. in einer Klammer
Ich habe es ausprobiert und es gibt viele Fehler


Brauche einen kompletten quelltext mit Deklarationen
Benutz wird nur ein Shape
HenryHux
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 542
Erhaltene Danke: 33

Windows 7 Premium
Delphi XE, Eclipse
BeitragVerfasst: Di 25.01.11 16:09 
Der Text sollte so eigentlich richtig sein.
Wähle bei den Events der Form das Event KeyDown aus und Doppelklicke es.
Danach solltest du das Grundgerüst haben.
Ein var kann übrigens auch in den Parametern stehen.
Lies dir dazu mal ein Kapitel über die call by reference durch. -> de.wikibooks.org/wik...call_by_reference.29

Lg

Für diesen Beitrag haben gedankt: Zlatan
MaxWurzel
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 77
Erhaltene Danke: 10



BeitragVerfasst: Di 25.01.11 16:10 
Hoch und runter geht ebenso.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  case key of
    VK_Left: shape1.Left := shape1.Left -1;
    VK_Right: shape1.Left := shape1.Left +1;
    VK_Up: shape1.Top := shape1.Top -1;
    VK_Down: shape1.Top := shape1.Top +1;
  end;
end;

Für diesen Beitrag haben gedankt: Zlatan
Zlatan Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 175



BeitragVerfasst: Di 25.01.11 16:14 
sorry funktioniert doch aber trotzdem weiß ich nicht wie hoch und runter geht
jetzt schreibst du es :? DANKE
Zlatan Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 175



BeitragVerfasst: Di 25.01.11 16:17 
eine frage hätte ich noch was ist mit diagonal gehen?
Namenlosnameless
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 259
Erhaltene Danke: 6

Windows XP Home Edition, Windos Vista
C#
BeitragVerfasst: Di 25.01.11 16:34 
In in dem du 2 Pfeile kombinierst

_________________
1:<<Life sucks!!>> 2:<< Well okay>> 1: <<Just Yours>> 2:<<Ohmph>>
Zlatan Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 175



BeitragVerfasst: Di 25.01.11 16:36 
wenn ich 2 pfeile gleichzeitig drücke geht das shape in die richtung, wo ich zuerst gedrückt habe
diagonal kann es noch nicht gehen
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Di 25.01.11 17:53 
Das wird so auch nie gehen. Das geht nur mit GetKeyState / GetAsyncKeyState oder ähnlichem, wenn du den Status der Tasten abfragst.
Zlatan Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 175



BeitragVerfasst: Di 25.01.11 18:02 
Was??? :?:
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Di 25.01.11 18:13