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.

January 3rd, 2011, 11:30 PM

hypheni

Re: Press Enter Twice

if (count != 0)

where did you defined count ?

January 4th, 2011, 03:42 AM

alone882

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

January 4th, 2011, 07:14 AM

alone882

Re: Press Enter Twice

Pls somebody help :/

January 4th, 2011, 07:14 AM

Igor Vartanov

Re: Press Enter Twice

Quote:

No one will work

... until you make pressCount be static.

January 4th, 2011, 11:30 AM

alone882

Re: Press Enter Twice

Finally I figure out how to solve this problem, thank you Igor

January 4th, 2011, 02:11 PM

Igor Vartanov

Re: Press Enter Twice

You're welcome. :)

January 4th, 2011, 07:04 PM

Amleto

Re: Press Enter Twice

count isnt defined anywhere (in scope or in class declaration)

January 5th, 2011, 12:17 AM

hypheni

Re: Press Enter Twice

If still not solved here is code snippet.

Code:

BOOL CTESDlg::PreTranslateMessage(MSG* pMsg)
{
static int co = 0;