static LRESULT CALLBACK UserWindowWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { Win32UserWindow* window = Win32UserWindow::FromWindow(hWnd); if (!window) return DefWindowProc(hWnd, message, wParam, lParam); LRESULT handled = 0; if (window->HasTransparentBackground()) { if (message == WM_ERASEBKGND) { handled = 1; } else if (message == WM_TIMER && wParam == window->GetTimer()) { window->UpdateBitmap(); handled = 1; } else { IWebView* webView = window->GetWebView(); if (webView) { handled = webView->forwardingWindowProc( reinterpret_cast<OLE_HANDLE>(hWnd), message, wParam, lParam); // WebKit sometimes causes WM_PAINT messages to fire. We need to ensure // we call DefWindowProc in this case, otherwise Windows will assume // that it was not handled and continue to flood us with WM_PAINT messages. if (message == WM_PAINT) { // Calling UpdateBitmap here, assures smooth resizing. window->UpdateBitmap(); handled = 0; } } } } switch (message) { case WM_CLOSE: if (!window->Close()) handled = 1; break; case WM_GETMINMAXINFO: window->GetMinMaxInfo((MINMAXINFO*) lParam); handled = 1; break; case WM_SIZE: window->FireEvent(Event::RESIZED); if (wParam == SIZE_MAXIMIZED) { window->FireEvent(Event::MAXIMIZED); window->ResizeSubViews(); } else if (wParam == SIZE_MINIMIZED) { window->FireEvent(Event::MINIMIZED); } else { window->ResizeSubViews(); } handled = 1; break; case WM_SETFOCUS: // The focus event will be fired by the UIDelegate window->Focus(); // Focus the WebView and not the main window. handled = 1; break; case WM_MOVE: window->FireEvent(Event::MOVED); break; case WM_SHOWWINDOW: window->FireEvent(((BOOL)wParam) ? Event::SHOWN : Event::HIDDEN); break; case WM_MENUCOMMAND: { HMENU nativeMenu = (HMENU) lParam; UINT position = (UINT) wParam; UINT itemId = GetMenuItemID(nativeMenu, position); if (itemId == WEB_INSPECTOR_MENU_ITEM_ID) { handled = 1; window->ShowInspector(false); } else { handled = Win32MenuItem::HandleClickEvent(nativeMenu, position); } } break; } if (!handled) return DefWindowProc(hWnd, message, wParam, lParam); else return handled; }