Exemple #1
0
LRESULT WINAPI MsgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
    switch( msg )
    {
        case WM_DESTROY:
            PostQuitMessage( 0 );
            return 0;
		case WM_KEYDOWN:
			switch( wParam )
			{
			case VK_UP:
				kServ.OnUpPressed();
				break;
			case VK_DOWN:
				kServ.OnDownPressed();
				break;
			case VK_LEFT:
				kServ.OnLeftPressed();
				break;
			case VK_RIGHT:
				kServ.OnRightPressed();
				break;
			case VK_SPACE:
                kServ.OnSpacePressed();
				break;
			case VK_RETURN:
				kServ.OnEnterPressed();
				break;
			}
			break;
		case WM_KEYUP:
   			switch( wParam )
			{
			case VK_UP:
				kServ.OnUpReleased();
				break;
			case VK_DOWN:
				kServ.OnDownReleased();
				break;
			case VK_LEFT:
				kServ.OnLeftReleased();
				break;
			case VK_RIGHT:
				kServ.OnRightReleased();
				break;
			case VK_SPACE:
				kServ.OnSpaceReleased();
				break;
			case VK_RETURN:
				kServ.OnEnterReleased();
				break;
			}
    }

    return DefWindowProc( hWnd, msg, wParam, lParam );
}
Exemple #2
0
LRESULT WINAPI MsgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	/*Graphics *pGraphicsWTF = reinterpret_cast<Graphics *>(static_cast<LONG_PTR>(
		::GetWindowLongPtrW(
			hWnd,
			GWLP_USERDATA
			)));
			*/

	switch (msg)
	{
	case WM_DESTROY:
		PostQuitMessage(0);
		break;
		/*
	case WM_SETCURSOR:
	{
		WORD ht = LOWORD(lParam);
		static bool hiddencursor = false;
		if (HTCLIENT == ht && !hiddencursor)
		{
			hiddencursor = true;
			ShowCursor(false);
		}
		else if (HTCLIENT != ht && hiddencursor)
		{
			hiddencursor = false;
			ShowCursor(true);
		}
	}
	break;
	*/
	
		
		// ************ KEYBOARD MESSAGES ************ //
	case WM_KEYDOWN:
		switch (wParam)
		{
		case VK_UP:
			kServ.OnUpPressed();
			break;
		case VK_DOWN:
			kServ.OnDownPressed();
			break;
		case VK_LEFT:
			kServ.OnLeftPressed();
			break;
		case VK_RIGHT:
			kServ.OnRightPressed();
			break;
		case VK_SPACE:
			kServ.OnSpacePressed();
			break;
		case VK_RETURN:
			kServ.OnEnterPressed();
			break;
		case VK_LCONTROL:
			kServ.OnLControlPressed();
			break;
		}
		break;

	case WM_KEYUP:
		switch (wParam)
		{
		case VK_UP:
			kServ.OnUpReleased();
			break;
		case VK_DOWN:
			kServ.OnDownReleased();
			break;
		case VK_LEFT:
			kServ.OnLeftReleased();
			break;
		case VK_RIGHT:
			kServ.OnRightReleased();
			break;
		case VK_SPACE:
			kServ.OnSpaceReleased();
			break;
		case VK_RETURN:
			kServ.OnEnterReleased();
			break;
		case VK_LCONTROL:
			kServ.OnLControlReleased();
			break;
		}	
		break;
		// ************ END KEYBOARD MESSAGES ************ //

		// ************ MOUSE MESSAGES ************ //
	case WM_MOUSEMOVE:
	{
		int x = (short)LOWORD(lParam); 
		int y = (short)HIWORD(lParam); 
		if (x > 0 && x < 1600 && y > 0 && y < 900)
		{
			mServ.OnMouseMove(x, y);
			if (!mServ.IsInWindow())
			{
				SetCapture(hWnd);
				mServ.OnMouseEnter();
			}
		}
		else
		{
			if (wParam & (MK_LBUTTON | MK_RBUTTON))
			{
				x = max(0, x);
				x = min(1599, x);
				y = max(0, y);
				y = min(899, y);
				mServ.OnMouseMove(x, y);
			}
			else
			{
				ReleaseCapture();
				mServ.OnMouseLeave();
				mServ.OnLeftReleased();
				mServ.OnRightReleased();
			}
		}
	}
	break;
	case WM_LBUTTONDOWN:
		mServ.OnLeftPressed();
		//nowyKoniec = true; /////////////////////////////////////////////////
		break;
	case WM_RBUTTONDOWN:
		mServ.OnRightPressed();
		break;
	case WM_LBUTTONUP:
		mServ.OnLeftReleased();
		break;
	case WM_RBUTTONUP:
		mServ.OnRightReleased();
		break;
		// ************ END MOUSE MESSAGES ************ //
	}

	return DefWindowProc(hWnd, msg, wParam, lParam);
}
Exemple #3
0
LRESULT WINAPI MsgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch (msg)
	{
	case WM_DESTROY:
		PostQuitMessage(0);
		return 0;

		// ************ KEYBOARD MESSAGES ************ //
	case WM_KEYDOWN:
		switch (wParam)
		{
		case VK_UP:
			kServ.OnUpPressed();
			break;
		case VK_DOWN:
			kServ.OnDownPressed();
			break;
		case VK_LEFT:
			kServ.OnLeftPressed();
			break;
		case VK_RIGHT:
			kServ.OnRightPressed();
			break;
		case VK_SPACE:
			kServ.OnSpacePressed();
			break;
		case VK_RETURN:
			kServ.OnEnterPressed();
			break;
		}
		break;
	case WM_KEYUP:
		switch (wParam)
		{
		case VK_UP:
			kServ.OnUpReleased();
			break;
		case VK_DOWN:
			kServ.OnDownReleased();
			break;
		case VK_LEFT:
			kServ.OnLeftReleased();
			break;
		case VK_RIGHT:
			kServ.OnRightReleased();
			break;
		case VK_SPACE:
			kServ.OnSpaceReleased();
			break;
		case VK_RETURN:
			kServ.OnEnterReleased();
			break;
		}
		break;
		// ************ END KEYBOARD MESSAGES ************ //

		// ************ MOUSE MESSAGES ************ //
	case WM_MOUSEMOVE:
	{
		int x = (short)LOWORD(lParam);
		int y = (short)HIWORD(lParam);
		if (x > 0 && x < SCREENWIDTH && y > 0 && y < SCREENHEIGHT)
		{
			mServ.OnMouseMove(x, y);
			if (!mServ.IsInWindow())
			{
				SetCapture(hWnd);
				mServ.OnMouseEnter();
			}
		}
		else
		{
			if (wParam & (MK_LBUTTON | MK_RBUTTON))
			{
				x = max(0, x);
				x = min((SCREENWIDTH - 1), x);
				y = max(0, y);
				y = min((SCREENHEIGHT - 1), y);
				mServ.OnMouseMove(x, y);
			}
			else
			{
				ReleaseCapture();
				mServ.OnMouseLeave();
				mServ.OnLeftReleased();
				mServ.OnRightReleased();
			}
		}
	}
	break;
	case WM_LBUTTONDOWN:
		mServ.OnLeftPressed();
		break;
	case WM_RBUTTONDOWN:
		mServ.OnRightPressed();
		break;
	case WM_LBUTTONUP:
		mServ.OnLeftReleased();
		break;
	case WM_RBUTTONUP:
		mServ.OnRightReleased();
		break;
		// ************ END MOUSE MESSAGES ************ //
	}

	return DefWindowProc(hWnd, msg, wParam, lParam);
}