Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi frage zu getasynckeystate (https://www.delphipraxis.net/119596-frage-zu-getasynckeystate.html)

Spiderpig_GER_15 28. Aug 2008 21:47


frage zu getasynckeystate
 
Hallo,

ich benutze getasynckeystate um zu schauen ob enter und shift gleichzeitig gedrückt sind, mein Problem dabei ist, das das Programm, wenn ich shift vorher drücke und enter zeitversetzt danach denkt das es gleichzeitig wäre. Das soll natürlich nicht sein, gibt es Alternativen bzw. eine Lösung für meinen Ansatz?

MfG

Spiderpig

sx2008 28. Aug 2008 22:55

Re: frage zu getasynckeystate
 
Wie wertest du den Rückgabewert von GetAsyckKeyState aus?
Delphi-Quellcode:
// Trick: die Bedingung < 0 prüft, ob das höchstwertige Bit (MSB) gesetzt ist
if (GetAsyckKeyState(VK_ENTER)<0) and (GetAsyckKeyState(VK_RSHIFT)<0) then
  ShowMessage('Right-Shift + Enter');

Spiderpig_GER_15 29. Aug 2008 18:47

Re: frage zu getasynckeystate
 
momentan überprüfe ich es wie folgt:

mit keyup schaue ich ob enter gedrückt ist, und mit getasynckeystate schaue ich ob zusätzlich shift gedrückt ist.

Delphi-Quellcode:
keyup...
if (key = vk_return) and (getasynckeystate(vk_shift)>0) then
...
hilföööö

Spiderpig

Matze 29. Aug 2008 19:26

Re: frage zu getasynckeystate
 
Es sieht für mich so aus, als ob du es nur innerhalb eines Controls benötigst und OnKeyDown verwenden kannst. Dann geht das so (ohne GetAsyncKeyState):

Delphi-Quellcode:
if (ssShift in Shift) and (Key = VK_RETURN) then
  // ...
Grüße

Spiderpig_GER_15 29. Aug 2008 21:04

Re: frage zu getasynckeystate
 
was ist denn sShift?

MfG

Spiderpig

SirThornberry 29. Aug 2008 21:37

Re: frage zu getasynckeystate
 
einer der Parameter im OnKeyDown und OnKeyUp

Noobinator 29. Aug 2008 21:37

Re: frage zu getasynckeystate
 
schau dir mal deine Funktion Onkeydown an:

Delphi-Quellcode:
FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
und dazu die Hilfe:

Zitat:

TShiftState (Typ):
Wert-->Bedeutung

ssShift --> Die Taste Umschalt wird gedrückt gehalten.
ssAlt --> Die Taste Strg wird gedrückt gehalten.
ssLeft --> Die linke Maustaste wird gedrückt gehalten.
ssRight --> Die rechte Maustaste wird gedrückt gehalten.
ssMiddle --> Die mittlere Maustaste wird gedrückt gehalten.
ssDouble --> Es wurde mit der Maus doppelgeklickt.

Spiderpig_GER_15 29. Aug 2008 22:39

Re: frage zu getasynckeystate
 
dankü schön
:firejump: :dp:


Alle Zeitangaben in WEZ +1. Es ist jetzt 15:34 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz