-
Re: Press Enter Twice
You need to understand the code you write. Precisely, what count means and how it differs from pressCount. :)
Then you need to think about exact meaning of "press Enter twice". If you press Enter and wait 24 hours before pressing Enter second time, will it be two "single presses" or a single "press twice"? Your code tells me the second is true. Now you tell yourself whether it is.
-
Re: Press Enter Twice
if (count != 0)
where did you defined count ?
-
Re: Press Enter Twice
Sry, but this code wont work I try
Code:
switch( Key )
{
case 'VK_RETURN':
{
pressCount = ++pressCount % 2 }
if (pressCount != 0)
{
//first time
}
else
{
//second time
pressCount = 0;
}
break;
And
Code:
int pressCount = 0;
switch( Key )
{
case 'VK_RETURN:
{
if (pressCount == 0)
{
//first time
++pressCount;
}
else
{
//second time
pressCount = 0;
}
}
break;
No one will work
-
Re: Press Enter Twice
-
Re: Press Enter Twice
... until you make pressCount be static.
-
Re: Press Enter Twice
Finally I figure out how to solve this problem, thank you Igor
-
Re: Press Enter Twice
-
Re: Press Enter Twice
count isnt defined anywhere (in scope or in class declaration)
-
Re: Press Enter Twice
If still not solved here is code snippet.
Code:
BOOL CTESDlg::PreTranslateMessage(MSG* pMsg)
{
static int co = 0;
if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_RETURN)
{
pMsg->wParam = NULL;
++co;
if (co==2)
AfxMessageBox(L"Twice Pressed");
}
return CDialog::PreTranslateMessage(pMsg);
}