Autor Beitrag
futti
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 44

WIN 2000
D3 Prof, Delphi 2005 Prof
BeitragVerfasst: Di 18.10.05 13:39 
Hallo da draußen,

wie kann ich in Delphi 2005 Win32 die Länge eines Tastendrucks abfragen? Geht das mit TTimer? Wenn ja, wie. Habe ich nämlich noch nie verwendet.

Vielen Dank und viele Grüße
Futti
digi_c
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1905

W98, XP
D7 PE, Lazarus, WinAVR
BeitragVerfasst: Di 18.10.05 13:48 
Du benötigst die Funktion Suche in: Delphi-Forum, Delphi-Library GETTICKCOUNT die dann bei Tastendruck eine globale Variable füllt und beim loslassen die Differenz aus der LoslassZeit und der globalen Startzeit bildet.
futti Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 44

WIN 2000
D3 Prof, Delphi 2005 Prof
BeitragVerfasst: Mi 19.10.05 12:56 
Habe Gettickcount ausprobiert.
Die Funktion liefert angeblich Millisekunden zurück.
Wenn ich ca. 3 Sekunden die Taste drücke, bekomme ich als Ergebnis den Wert 16. Das kann dann wohl nicht stimmen.
Muss ich evt. noch ein paar Voreinstellungen vornehmen?

Gruß Futti
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 480

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Mi 19.10.05 12:59 
Wie berechnest du denn den Wert 16? Normalerweise sollte der Ansatz nämlich klappen, denke ich...

_________________
We are, we were and will not be.
futti Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 44

WIN 2000
D3 Prof, Delphi 2005 Prof
BeitragVerfasst: Mi 19.10.05 13:03 
Wenn die Taste gedrückt wird schreibe ich den Wert, der von GetTickCount geliefert wird in eine Variable <Start>. Wird die Taste losgelassen schreibe ich den Wert aus Gettickcount in <Stop>.
<Diff> := <Stop> - <Start>;
<Diff> hat bei mir den Wert 16.
godworx
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 27



BeitragVerfasst: Mi 19.10.05 13:35 
die variable in die die werte gespeichert werden muss vom Typ Cardinal sein... dann gehts
ausblenden Delphi-Quelltext
1:
2:
3:
Zeit := GetTickCount;
//lalala
label1.Caption:= IntToStr((GetTickCount - Zeit)div 1000 ); // div 1000 rechnet in sek um


Moderiert von user profile iconraziel: Code- durch Delphi-Tags ersetzt
futti Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 44

WIN 2000
D3 Prof, Delphi 2005 Prof
BeitragVerfasst: Do 20.10.05 08:46 
Habe die Variablen in cardinal umgestellt. Jetzt kommt bei der Berechnung 0 raus. Ich verstehe das nicht!
Vielleicht hat jemand noch eine andere Idee...
futti Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 44

WIN 2000
D3 Prof, Delphi 2005 Prof
BeitragVerfasst: Do 20.10.05 10:13 
Tja, manchmal sieht man den Wald vor lauter Bäumen nicht. Wenn die Taste gedrückt gehalten wird, wird das OnkeyDown-Event immer wieder neu ausgelöst und in meinem Code auch die Zeit immer wieder neu berechnet. Deshalb ist die Differenz nie so groß wie gedacht.

Danke für Alles :oops: :P