LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_CREATE: return OnCreateWindow(hwnd); case WM_COMMAND: switch (LOWORD(wParam)) { case IDM_EXIT: DestroyWindow(hwnd); break; case ID_FILE_OPENFILE: OnFileOpen(hwnd); break; case ID_FILE_OPENURL: OnOpenURL(hwnd); break; default: return DefWindowProc(hwnd, message, wParam, lParam); } break; case WM_PAINT: OnPaint(hwnd); break; case WM_SIZE: OnResize(LOWORD(lParam), HIWORD(lParam)); break; case WM_ERASEBKGND: // Suppress window erasing, to reduce flickering while the video is playing. return 1; case WM_DESTROY: PostQuitMessage(0); break; case WM_CHAR: OnKeyPress(wParam); break; case WM_APP_PLAYER_EVENT: OnPlayerEvent(hwnd, wParam); break; default: return DefWindowProc(hwnd, message, wParam, lParam); } return 0; }
LRESULT ofxWMFVideoPlayer::WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_DESTROY: PostQuitMessage(0); break; case WM_APP_PLAYER_EVENT: OnPlayerEvent(hwnd, wParam); break; default: return DefWindowProc(hwnd, message, wParam, lParam); } return 0; }
//----------------------------------------------------------------------------- // Name: MsgProc() // Desc: The window's message handler //----------------------------------------------------------------------------- LRESULT WINAPI MsgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { CContextManager& context = *(CEngine::GetSingleton().getContextManager()); CInputManagerImplementation *inputManager = dynamic_cast<CInputManagerImplementation*>(CInputManager::GetInputManager()); bool WasDown = false, IsDown = false, Alt = false; switch (msg) { case WM_SETFOCUS: if (inputManager) { inputManager->SetFocus(true); } return 0; case WM_KILLFOCUS: if (inputManager) { inputManager->SetFocus(false); } return 0; case WM_SYSKEYDOWN: case WM_SYSKEYUP: case WM_KEYDOWN: case WM_KEYUP: WasDown = ((lParam & (1 << 30)) != 0); IsDown = ((lParam & (1 << 31)) == 0); Alt = ((lParam & (1 << 29)) != 0); if (IsDown && !WasDown) { bool consumed = false; switch (wParam) { case VK_RETURN: if (Alt) { //WINDOWPLACEMENT windowPosition = { sizeof(WINDOWPLACEMENT) }; //GetWindowPlacement(hWnd, &windowPosition); ToggleFullscreen(hWnd); consumed = true; } break; case VK_ESCAPE: if ( Alt ) { PostQuitMessage( 0 ); consumed = true; } break; case VK_F4: if (Alt) { PostQuitMessage(0); consumed = true; } break; } if (consumed) { return 0; } } if (inputManager && inputManager->HasFocus()) { if (inputManager->KeyEventReceived(wParam, lParam)) { return 0; } } break; case WM_MOUSEMOVE: if (inputManager && inputManager->HasFocus()) { int xPosAbsolute = GET_X_LPARAM(lParam); int yPosAbsolute = GET_Y_LPARAM(lParam); inputManager->UpdateCursor(xPosAbsolute, yPosAbsolute); return 0; } break; case WM_SIZE: if (wParam != SIZE_MINIMIZED) { // TODO: Resetear el AntTeakBar TwWindowSize(0, 0); context.Resize(hWnd, (UINT)LOWORD(lParam), (UINT)HIWORD(lParam)); // TODO: Resetear el AntTeakBar TwWindowSize((UINT)LOWORD(lParam), (UINT)HIWORD(lParam)); if (CEngine::GetSingleton().getPlayerManager() != NULL) { CEngine::GetSingleton().getPlayerManager()->ResizeVideo((UINT)LOWORD(lParam), (UINT)HIWORD(lParam)); } } return 0; case WM_DESTROY: { PostQuitMessage(0); return 0; } case WM_APP_PLAYER_EVENT: { OnPlayerEvent(hWnd, wParam); break; } break; }//end switch( msg ) return DefWindowProc(hWnd, msg, wParam, lParam); }