Advertisement Jump to content
Sign in to follow this  
Calin

Win 32 API Keyboard Input *solved*

This topic is 4905 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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!