コード例 #1
0
ファイル: GameApp.cpp プロジェクト: flair2005/vr-bike
void CGameApp::WaitforStart()
{
	if (m_Reader.IsGameStart())
		return;

	MSG msg;
	memset(&msg,0,sizeof(msg));
	HANDLE hScreenSave = ScreenSave();
	if(hScreenSave)
	{
		HANDLE handle = CreateEvent(NULL, TRUE, FALSE, "StartGame");
		while (WaitForSingleObject(handle,100)==WAIT_TIMEOUT)
		{
			//if (PeekMessage(&msg,NULL,0,0,PM_REMOVE))
			//{
			//	switch( msg.message )
			//	{
			//	case WM_KEYDOWN:
			//		if(msg.wParam==VK_ESCAPE)
			//		{
			//			DWORD exitCode = 0;
			//			GetExitCodeProcess(hScreenSave, &exitCode);
			//			TerminateProcess(hScreenSave, exitCode);
			//			SetEvent(handle);
			//			PostQuitMessage( 0 );
			//		}
			//		return;
			//	case WM_DESTROY:
			//		{
			//			DWORD exitCode = 0;
			//			GetExitCodeProcess(hScreenSave, &exitCode);
			//			TerminateProcess(hScreenSave, exitCode);
			//			SetEvent(handle);
			//			PostQuitMessage( 0 );
			//		}
			//		return;
			//	}
			//}
			if (m_Reader.IsGameStart())
			{
				DWORD exitCode = 0;
				GetExitCodeProcess(hScreenSave, &exitCode);
				TerminateProcess(hScreenSave, exitCode);
				SetEvent(handle);
			}
		}

		CloseHandle(hScreenSave);
		CloseHandle(handle);
		SetForegroundWindow(m_hwnd);
		ShowWindow(m_hwnd, SW_SHOWNORMAL);
		SetFocus(m_hwnd);
	}
	
	return;

}
コード例 #2
0
LRESULT CALLBACK WndProc(	HWND	hWnd,
							UINT	uMsg,
							WPARAM	wParam,
							LPARAM	lParam)
{
	switch (uMsg)						
	{
		case WM_ACTIVATE:				
		{
			Active=(!HIWORD(wParam));
			return 0;					
		}

		case WM_SYSCOMMAND:				
		{
			switch (wParam)				
			{
				case SC_SCREENSAVE:		
				case SC_MONITORPOWER:	
				return 0;				
			}
			break;						
		}

		case WM_CLOSE:					
		{
			Done = true;
			return 0;					
		}

		case WM_KEYDOWN:				
		{
			Keys[wParam] = true;
			return 0;					
		}

		case WM_KEYUP:					
		{
			Keys[wParam] = false;
			if (wParam==VK_SNAPSHOT)
			{
				ScreenSave();
				return DefWindowProcW(hWnd,uMsg,wParam,lParam);
			}
			return 0;
		}
#ifdef MINIMALTWEAKER
		case WM_MOUSEMOVE:
		{
			POINT ap;
			GetCursorPos(&ap);
			ScreenToClient(hWnd,&ap);
			mx=ap.x;
			my=ap.y;
			return 0;
		}
        case WM_LBUTTONDOWN:
        {
            LeftButton=true;
			POINT ap;
			GetCursorPos(&ap);
			LeftShift=(wParam & MK_SHIFT)==0;
			LeftCtrl=(wParam & MK_CONTROL)==0;
			ScreenToClient(hWnd,&ap);
            lx=ap.x;
            ly=ap.y;
			return 0;
        }
        
		case WM_LBUTTONUP:
        {
            LeftButton=false;
            LeftButtonReleased=true;
			return 0;
        }
        
		case WM_RBUTTONDOWN:
        {
            RightButton=true;
			POINT ap;
			GetCursorPos(&ap);
			RightShift=(wParam & MK_SHIFT)==0;
			RightCtrl=(wParam & MK_CONTROL)==0;
			ScreenToClient(hWnd,&ap);
            rx=ap.x;
            ry=ap.y;
			return 0;
        }
        
		case WM_RBUTTONUP:
        {
            RightButton=false;
            RightButtonReleased=true;
			return 0;
        }
        
		case WM_MBUTTONDOWN:
        {
            MiddleButton=true;
			POINT ap;
			GetCursorPos(&ap);
			MidShift=(wParam & MK_SHIFT)==0;
			MidCtrl=(wParam & MK_CONTROL)==0;
			ScreenToClient(hWnd,&ap);
            mbx=ap.x;
            mby=ap.y;
			//DemoPlayback=false;
			return 0;
        }
        
		case WM_MBUTTONUP:
        {
            MiddleButton=false;
            MiddleButtonReleased=true;
			return 0;	
        }
#endif

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