| | |
| | | |
| | | // Try hooked procedure |
| | | LRESULT result; |
| | | bool handled = ctx->windowProc(hWnd, message, wParam, lParam, &result); |
| | | if (handled) { |
| | | if (ctx->windowProc(hWnd, message, wParam, lParam, &result)) { |
| | | return result; |
| | | } |
| | | |
| | |
| | | return ::CallWindowProcW(g_qtWindowProc, hWnd, message, wParam, lParam); |
| | | } |
| | | |
| | | Win32WindowContext::Win32WindowContext(QWindow *window, WindowItemDelegate *delegate) |
| | | : AbstractWindowContext(window, delegate), windowId(0) { |
| | | Win32WindowContext::Win32WindowContext(QWindow *window, WindowItemDelegatePtr delegate) |
| | | : AbstractWindowContext(window, std::move(delegate)), windowId(0) { |
| | | } |
| | | |
| | | Win32WindowContext::~Win32WindowContext() { |
| | |
| | | |
| | | bool Win32WindowContext::setup() { |
| | | auto winId = m_windowHandle->winId(); |
| | | Q_ASSERT(winId); |
| | | if (!winId) { |
| | | return false; |
| | | } |
| | | |
| | | // Install window hook |
| | | auto hWnd = reinterpret_cast<HWND>(winId); |
| | | auto qtWindowProc = reinterpret_cast<WNDPROC>(::GetWindowLongPtrW(hWnd, GWLP_WNDPROC)); |
| | | Q_ASSERT(qtWindowProc); |
| | | if (!qtWindowProc) { |
| | | QWK_WARNING << winLastErrorMessage(); |
| | | return false; |
| | | } |
| | | |
| | | if (::SetWindowLongPtrW(hWnd, GWLP_WNDPROC, |
| | | reinterpret_cast<LONG_PTR>(QWK_WindowsWndProc)) == 0) { |
| | | QWK_WARNING << winLastErrorMessage(); |
| | | return false; |
| | | } |
| | | ::SetWindowLongPtrW(hWnd, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(QWK_WindowsWndProc)); |
| | | |
| | | windowId = winId; |
| | | |