Jump to content

View more

Image of the Day

Adding some finishing touches...
Follow us for more
#screenshotsaturday #indiedev... by #MakeGoodGames https://t.co/Otbwywbm3a
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

escape key and sutting down a window

4: Adsense

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   

421
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 fastcall22   Moderators   

10757
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.
zlib: eJzVVLsSAiEQ6/1qCwoK i7PxA/2S2zMOZljYB1TO ZG7OhUtiduH9egZQCJH9 KcJyo4Wq9t0/RXkKmjx+ cgU4FIMWHhKCU+o/Nx2R LEPgQWLtnfcErbiEl0u4 0UrMghhZewgYcptoEF42 YMj+Z1kg+bVvqxhyo17h nUf+h4b2W4bR4XO01TJ7 qFNzA7jjbxyL71Avh6Tv odnFk4hnxxAf4w6496Kd OgH7/RxC

#3 phil67rpg   Members   

421
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   Members   

8710
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.