Jump to content

  • Log In with Google      Sign In   
  • Create Account

escape key and sutting down a window


Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
3 replies to this topic

#1   Members   -  Reputation: 168

Like
0Likes
Like

Posted 18 November 2012 - 03:17 PM

I am using the following code to shut down a window using the escape key. I want to only have the escape key shut down the window but for some reason this code shuts down the window no matter what key I press.
	case WM_KEYDOWN:		
		if(wParam==VK_ESCAPE)
		{
		PostQuitMessage(0);
		break;
		}
I have tried the WM_CHAR message as well but to no help.


#2   Moderators   -  Reputation: 9448

Like
2Likes
Like

Posted 18 November 2012 - 03:35 PM

... but for some reason this code shuts down the window no matter what key I press.

	case WM_KEYDOWN:		
		if(wParam==VK_ESCAPE)
		{
		PostQuitMessage(0);
		break;
		}

Hi Phil,

Take note of the location of your break statement here. If any other key is pressed, then the break statement isn't reached, and the code falls through to the next case statement, which I am assuming also has a PostQuitMessage. For example:
int i;
cin >> i;
switch ( i ) {
case 0:  cout << 'A';
case 1:  cout << 'B'; break;
}
When i is 0, "AB" is printed.
gzip: H4sIAAAAAAAEAG1QTUvEMBC991e8nvaiFfYoS7yo sLCo6MnjtJ1ugmkiyWRL/72z3T1YEQIJ8z4zA2Xp yPvt1qBpGrRFIJZkk9FyRyUzHCbKIHgn4hnZOrm1 TD0mG0HCCs+QGDGWziKXI6Wm2n++GYwUVH2mrGEE PnGCVQ8K8+JYfXA6URDEQfMZh5h6g5eoAlWJdeEI bbH2qYZf7XMUfw8f/Q0oMeZYNL9/WHF0uFEshvMr XYujd9SycFb+F18QcSOvlJauZ8ejqevdnV7/d550 e0t6prmunh73Bu+vz4c/XUeOQXfJgvKNkhf95U8/ Dtgmy5IBAAA=

#3   Members   -  Reputation: 168

Like
0Likes
Like

Posted 18 November 2012 - 03:41 PM

cool thanks that really helped, sometimes I need another pair of eyes to look at my code.

#4   Crossbones+   -  Reputation: 7277

Like
0Likes
Like

Posted 19 November 2012 - 08:34 PM

fastcall22 : So boss he can debug code that isn't even onscreen. Posted Image
void hurrrrrrrr() {__asm sub [ebp+4],5;}

There are ten kinds of people in this world: those who understand binary and those who don't.




Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.




PARTNERS