I need some kind of routine that can detect when the user has pressed the escape button.
I need some kind of routine that can detect when the user has pressed the escape button.
Code:LRESULT CALLBACK TheWindowProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam) { //which message did we get? switch(uMsg) { case WM_KEYDOWN: { //check for escape key if(wParam==VK_ESCAPE) { DestroyWindow(hWndMain); } return(0);//
There are some real morons in this world please do not become one of them, do not become a victim of moronitis. PROGRAMMING IS THE FUTURE...THE FUTURE IS NOW!!!!!!!!!
"...The only real game I thank in the world is baseball..." --Babe Ruth
"Life is beautiful"-Don Corleone right before he died.
"The expert on anything was once a beginner" -Baseball poster I own.
Left cprog on 1-3-2005. Don't know when I am coming back. Thanks to those who helped me over the years.
Example of what I mean:
bool done = false;
while(done == false)
{
//if(userhitsescape) {done = true;}
xpos += 1;
DrawScene();
}
return 0;
}
Are you using Win32 API or what? Please be a little more specific.
he says he's using SDL or something like that, I am not really informed on what SDL is, I heard it was like a Direct X wrapper or something, I dont' know.
There are some real morons in this world please do not become one of them, do not become a victim of moronitis. PROGRAMMING IS THE FUTURE...THE FUTURE IS NOW!!!!!!!!!
"...The only real game I thank in the world is baseball..." --Babe Ruth
"Life is beautiful"-Don Corleone right before he died.
"The expert on anything was once a beginner" -Baseball poster I own.
Left cprog on 1-3-2005. Don't know when I am coming back. Thanks to those who helped me over the years.
well all I need is a generic way of detecting whether the escape key is being pressed down...You know how the ASCII characters have numbers assigned to them? You can go char i = 112 and it ends up being a symbol.
I was wondering if the escape button also had a numerical identity.
Um, so you never did answer the question. In your winproc, if you are using Win32, simply check the WM_KEYDOWN message, switch on the wParam, and have a case for value 27 or VK_ESCAPE as stated above. I guess to answer your generic quetsion it would be 27 as I just wrote for the value assigned to it.
"...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers
Originally posted by MrWizard
Um, so you never did answer the question. In your winproc, if you are using Win32, simply check the WM_KEYDOWN message, switch on the wParam, and have a case for value 27 or VK_ESCAPE as stated above. I guess to answer your generic quetsion it would be 27 as I just wrote for the value assigned to it.
I told him that above man......he says he doens't have a winproc.
There are some real morons in this world please do not become one of them, do not become a victim of moronitis. PROGRAMMING IS THE FUTURE...THE FUTURE IS NOW!!!!!!!!!
"...The only real game I thank in the world is baseball..." --Babe Ruth
"Life is beautiful"-Don Corleone right before he died.
"The expert on anything was once a beginner" -Baseball poster I own.
Left cprog on 1-3-2005. Don't know when I am coming back. Thanks to those who helped me over the years.
Well then I told him at the end of my post the value he seeks is 27.
"...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers
Is this possible outside of winproc?
There are some real morons in this world please do not become one of them, do not become a victim of moronitis. PROGRAMMING IS THE FUTURE...THE FUTURE IS NOW!!!!!!!!!
"...The only real game I thank in the world is baseball..." --Babe Ruth
"Life is beautiful"-Don Corleone right before he died.
"The expert on anything was once a beginner" -Baseball poster I own.
Left cprog on 1-3-2005. Don't know when I am coming back. Thanks to those who helped me over the years.
Yep, I assume he's talking about a text based game here. Or something like that. Also you will need conio.h for the kbhit function.
If this isn't what he meant, I think you'll agree with me he needs to post the whole source or be rather specific, I don't have ESP.Code:if( kbhit() ) { keyCode = getch(); // Escape key pressed if( keyCode == 27 ) { // Do something!!! } }
EDIT: Man, Dual-Catfish, that game on the ascii page with clicking as many boxes as you can is TOOOO GOOOOD!!!
Last edited by MrWizard; 05-24-2002 at 10:25 PM.
"...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers
STFW.
http://www.asciitable.com
And, if you didn't know, you can use the little 'search' button at the top of the page. This question has been asked 10000 times.
yeah yeah yeah, it gets old, stop telling people that. obviously someone with 100+ posts has heard that plenty of times. if I hear that one more time I'm never going to use the search thing again.
and yes I did try using the search function, and no they don't answer my question, and no it hasn't been answered 10000 times
This is the second thread that appeared when I searched for the words press & escape.
http://www.cprogramming.com/cboard/s...t=press+escape
I know it doesn't answer the question directly, but someone with 100+ posts should be able to see where it's headed.
Demonographic rhinology is not the only possible outcome, but why take the chance