///////////////////////////////////////////////////////
| 1295 | |
| 1296 | //////////////////////////////////////////////////////////// |
| 1297 | LRESULT CALLBACK WindowImplWin32::globalOnEvent(HWND handle, UINT message, WPARAM wParam, LPARAM lParam) |
| 1298 | { |
| 1299 | // Associate handle and Window instance when the creation message is received |
| 1300 | if (message == WM_CREATE) |
| 1301 | { |
| 1302 | // Get WindowImplWin32 instance (it was passed as the last argument of CreateWindow) |
| 1303 | auto window = reinterpret_cast<LONG_PTR>(reinterpret_cast<CREATESTRUCT*>(lParam)->lpCreateParams); |
| 1304 | |
| 1305 | // Set as the "user data" parameter of the window |
| 1306 | SetWindowLongPtrW(handle, GWLP_USERDATA, window); |
| 1307 | } |
| 1308 | |
| 1309 | // Get the WindowImpl instance corresponding to the window handle |
| 1310 | WindowImplWin32* window = handle ? reinterpret_cast<WindowImplWin32*>(GetWindowLongPtr(handle, GWLP_USERDATA)) : nullptr; |
| 1311 | |
| 1312 | // Forward the event to the appropriate function |
| 1313 | if (window) |
| 1314 | { |
| 1315 | window->processEvent(message, wParam, lParam); |
| 1316 | |
| 1317 | if (window->m_callback) |
| 1318 | return CallWindowProcW(reinterpret_cast<WNDPROC>(window->m_callback), handle, message, wParam, lParam); |
| 1319 | } |
| 1320 | |
| 1321 | // We don't forward the WM_CLOSE message to prevent the OS from automatically destroying the window |
| 1322 | if (message == WM_CLOSE) |
| 1323 | return 0; |
| 1324 | |
| 1325 | // Don't forward the menu system command, so that pressing ALT or F10 doesn't steal the focus |
| 1326 | if ((message == WM_SYSCOMMAND) && (wParam == SC_KEYMENU)) |
| 1327 | return 0; |
| 1328 | |
| 1329 | return DefWindowProcW(handle, message, wParam, lParam); |
| 1330 | } |
| 1331 | |
| 1332 | } // namespace sf::priv |
nothing calls this directly
no test coverage detected