-
January 3rd, 2011, 05:21 PM
#16
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.
Best regards,
Igor
-
January 4th, 2011, 12:30 AM
#17
Re: Press Enter Twice
if (count != 0)
where did you defined count ?
-
January 4th, 2011, 04:42 AM
#18
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, 08:14 AM
#19
-
January 4th, 2011, 08:14 AM
#20
Re: Press Enter Twice
... until you make pressCount be static.
Best regards,
Igor
-
January 4th, 2011, 12:30 PM
#21
Re: Press Enter Twice
Finally I figure out how to solve this problem, thank you Igor
-
January 4th, 2011, 03:11 PM
#22
Re: Press Enter Twice
You're welcome.
Best regards,
Igor
-
January 4th, 2011, 08:04 PM
#23
Re: Press Enter Twice
count isnt defined anywhere (in scope or in class declaration)
-
January 5th, 2011, 01:17 AM
#24
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);
}
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|