Jump to content
  • Advertisement
Sign in to follow this  
Calin

Win 32 API Keyboard Input *solved*

This topic is 4839 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Here is my code from WINAPI MsgProc function:
LRESULT WINAPI MsgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
	HDC hDC;
	PAINTSTRUCT PaintStruct;


    switch( msg )
    {
	case WM_PAINT:
		{
			hDC=BeginPaint(hWnd, &PaintStruct);		

			// Do GDI drawing here

			EndPaint(hWnd, &PaintStruct);
			return 0;
		}
	case WM_KEYDOWN:
		{
			switch(wParam)
			{
				
			case VK_SPACE:
			case VK_ESCAPE:
				{
					PostQuitMessage( 0 );
					return 0;			
				
				}
                         }
			return 0;
		}
	
	case WM_KEYDOWN :
		if (wParam == 'S')
		zmov += 1;  // move my object
		break;


And here is the error I recive:
c:\documents and settings\calin\my documents\2. formats and culling\primitives1vb\sg0_03.cpp(184) : error C2196: case value '256' already used


Can anyone point me what am I doing wrong? Thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement
You're using a specific case (WM_KEYDOWN) twice in the same switch() statement, which you can't do. Merge the two sections like so:


switch( msg )
{
/*...*/
case WM_KEYDOWN:
switch( wParam )
{
case VK_SPACE:
case VK_ESCAPE:
PostQuitMessage( 0 );
return 0;

case 'S':
// move my object
zmov += 1;
break;
}

return 0;
/*...*/
}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!