public static IntPtr WndProc(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam) { IntPtr result = new IntPtr(); Window window = Window.GetWindowClass(); if (window == null) { return(WinUser.DefWindowProcW(hWnd, msg, wParam, lParam)); } InputManager inputManager = window.GetInputManager(); switch (msg) { case WinUser.WM_ACTIVATE: { if (wParam.ToInt32().HighWord() != 0) { // active } else { // inactive } return(new IntPtr(0)); } case WinUser.WM_SYSCOMMAND: { switch (wParam.ToInt32()) { case WinUser.SC_SCREENSAVE: case WinUser.SC_MONITORPOWER: return(new IntPtr(0)); } result = WinUser.DefWindowProcW(hWnd, msg, wParam, lParam); } break; case WinUser.WM_SETFOCUS: FocusCallback(window, true); break; case WinUser.WM_KILLFOCUS: FocusCallback(window, false); break; case WinUser.WM_CLOSE: case WinUser.WM_DESTROY: WinUser.PostQuitMessage(0); break; case WinUser.WM_KEYDOWN: case WinUser.WM_KEYUP: case WinUser.WM_SYSKEYDOWN: case WinUser.WM_SYSKEYUP: InputManager.KeyCallback(inputManager, (uint)lParam.ToInt32(), (uint)wParam.ToInt32(), msg); break; case WinUser.WM_LBUTTONDOWN: case WinUser.WM_LBUTTONUP: case WinUser.WM_RBUTTONDOWN: case WinUser.WM_RBUTTONUP: case WinUser.WM_MBUTTONDOWN: case WinUser.WM_MBUTTONUP: InputManager.MouseButtonCallback(hWnd, inputManager, msg, (uint)lParam.ToInt32().LowWord(), (uint)lParam.ToInt32().LowWord()); break; case WinUser.WM_SIZE: ResizeCallback(window, lParam.ToInt32().LowWord(), lParam.ToInt32().HighWord()); break; default: result = WinUser.DefWindowProcW(hWnd, msg, wParam, lParam); break; } return(result); }