Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


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 phil67rpg   Members   -  Reputation: 767

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.


Sponsor:

#2 fastcall22   Crossbones+   -  Reputation: 4389

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.
c3RhdGljIGNoYXIgeW91cl9tb21bMVVMTCA8PCA2NF07CnNwcmludGYoeW91cl9tb20sICJpcyBmYXQiKTs=

#3 phil67rpg   Members   -  Reputation: 767

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 Khatharr   Crossbones+   -  Reputation: 3031

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