Click here to Skip to main content
15,903,388 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionGetAsyncKeyState() and GetKeyState() [Solved] Pin
Rozis21-Mar-10 2:05
Rozis21-Mar-10 2:05 
AnswerRe: GetAsyncKeyState() and GetKeyState() Pin
CPallini21-Mar-10 2:48
mveCPallini21-Mar-10 2:48 
GeneralRe: GetAsyncKeyState() and GetKeyState() Pin
Rozis21-Mar-10 3:12
Rozis21-Mar-10 3:12 
GeneralRe: GetAsyncKeyState() and GetKeyState() Pin
CPallini21-Mar-10 3:23
mveCPallini21-Mar-10 3:23 
GeneralRe: GetAsyncKeyState() and GetKeyState() Gathered answers [modified] Pin
Rozis21-Mar-10 4:23
Rozis21-Mar-10 4:23 
AnswerRe: GetAsyncKeyState() and GetKeyState() Pin
Adam Roderick J21-Mar-10 4:53
Adam Roderick J21-Mar-10 4:53 
GeneralRe: GetAsyncKeyState() and GetKeyState() Pin
Rozis21-Mar-10 5:08
Rozis21-Mar-10 5:08 
GeneralRe: GetAsyncKeyState() and GetKeyState() Pin
Adam Roderick J21-Mar-10 6:11
Adam Roderick J21-Mar-10 6:11 
GetAsyncKeyState function determines whether a key is up or down at the time the function is called, and whether the key was pressed after a previous call to GetAsyncKeyState.

GetKeyState function retrieves the status of the specified virtual key. The status specifies whether the key is up, down, or toggled (on, off—alternating each time the key is pressed).

Above explanation as per msdn.


Now the case of SHIFT button applied to these cases to a normal application as example.

Now if you click the SHIFT key before calling this API in your application then
SHORT nVirtAsyc = GetAsyncKeyState(VK_LSHIFT);
SHORT nVirtSync = GetKeyState(VK_LSHIFT);
Async = 0
Sync = 1;
Now again you click SHIFT key
Aync = 0
Sync = 0

Now i think you got the point, GetKeyState gives the toggle values.
While GetAyncKeyState will be 1 when you have Pressed the SHIFT button.
Not the released button.

GetKeyState is useful for VK_NUMLOCK or VK_CAPITAL, which depends on toggle values
Величие не Бога может быть недооценена.
modified on Sunday, March 21, 2010 12:35 PM

GeneralRe: GetAsyncKeyState() and GetKeyState() Pin
Rozis21-Mar-10 10:44
Rozis21-Mar-10 10:44 
GeneralRe: GetAsyncKeyState() and GetKeyState() Pin
Adam Roderick J21-Mar-10 22:01
Adam Roderick J21-Mar-10 22:01 
AnswerRe: GetAsyncKeyState() and GetKeyState() Pin
Avi Berger21-Mar-10 5:21
Avi Berger21-Mar-10 5:21 
GeneralRe: GetAsyncKeyState() and GetKeyState() Pin
Rozis21-Mar-10 10:58
Rozis21-Mar-10 10:58 
QuestionGetKeyboardState + iexplore Pin
cjsc20-Mar-10 11:28
cjsc20-Mar-10 11:28 
AnswerRe: GetKeyboardState + iexplore Pin
«_Superman_»20-Mar-10 16:45
professional«_Superman_»20-Mar-10 16:45 
AnswerRe: GetKeyboardState + iexplore Pin
Avi Berger20-Mar-10 18:06
Avi Berger20-Mar-10 18:06 
AnswerRe: GetKeyboardState + iexplore Pin
Rajesh R Subramanian20-Mar-10 23:15
professionalRajesh R Subramanian20-Mar-10 23:15 
GeneralRe: GetKeyboardState + iexplore Pin
cjsc22-Mar-10 8:59
cjsc22-Mar-10 8:59 
GeneralRe: GetKeyboardState + iexplore Pin
cjsc25-Mar-10 10:42
cjsc25-Mar-10 10:42 
GeneralRe: GetKeyboardState + iexplore Pin
tomwg123456-Apr-10 10:22
tomwg123456-Apr-10 10:22 
QuestionProblem with Dialog... Pin
Aric Wang20-Mar-10 1:13
Aric Wang20-Mar-10 1:13 
AnswerRe: Problem with Dialog... Pin
Richard MacCutchan20-Mar-10 1:27
mveRichard MacCutchan20-Mar-10 1:27 
QuestionRe: Problem with Dialog... Pin
Avi Berger20-Mar-10 18:12
Avi Berger20-Mar-10 18:12 
AnswerRe: Problem with Dialog... Pin
Aric Wang24-Mar-10 4:47
Aric Wang24-Mar-10 4:47 
QuestionHow can chk any dialog is open over the main dialog? Pin
Le@rner19-Mar-10 22:26
Le@rner19-Mar-10 22:26 
AnswerRe: How can chk any dialog is open over the main dialog? Pin
«_Superman_»20-Mar-10 3:16
professional«_Superman_»20-Mar-10 3:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.