LRESULT CALLBACK ZPWebBrowserWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_SIZE: { // Resize the browser object to fit the window ResizeBrowser(hwnd, LOWORD(lParam), HIWORD(lParam)); return(0); } case WM_CREATE: { // Embed the browser object into our host window. We need do this only // once. Note that the browser object will start calling some of our // IOleInPlaceFrame and IOleClientSite functions as soon as we start // calling browser object functions in EmbedBrowserObject(). if (EmbedBrowserObject(hwnd)) return(-1); // Another window created with an embedded browser object //++gZPWebWindowCount; gZPWebWindowHWND = hwnd; // Success return(0); } case WM_DESTROY: { // Detach the browser object from this window, and free resources. UnEmbedBrowserObject(hwnd); { //Save the window size. RECT windowSize; GetWindowRect( hwnd, &windowSize ); gWindowX = windowSize.left; gWindowY = windowSize.top; gWindowWidth = windowSize.right - windowSize.left; gWindowHeight = windowSize.bottom - windowSize.top; } // One less window //--gZPWebWindowCount; gZPWebWindowHWND = NULL; HandleHistoryPanelClose(); // Free the OLE library. //OleUninitialize(); //Commented as OleInitialize is also commented // If all the windows are now closed, quit this app //if (!gZPWebWindowCount) PostQuitMessage(0); return(TRUE); } } return(DefWindowProc(hwnd, uMsg, wParam, lParam)); }
void QCefWebView::OnAfterCreated() { //qDebug() << __FUNCTION__; browser_state_ = kCreated; if (need_resize_) { //qDebug() << __FUNCTION__ << "need_resize_"; ResizeBrowser(size()); need_resize_ = false; } }
void QCefWebView::resizeEvent(QResizeEvent* e) { //qDebug() << __FUNCTION__ << e->size(); // On WinXP, if you load a url immediately after constructed, you will // CreateBrowser() with the wrong Size(). At the same time, it calls // resizeEvent() to resize. However the browser has not been created now, // ResizeBrowser() will fail, and it won't displayed with the right size. // Although resize(0, 0) can fix it, the other platforms maybe // give you the right size and it will make CreateBrowser() later. switch (browser_state_) { case kNone: CreateBrowser(e->size()); break; case kCreating: need_resize_ = true; break; default: ResizeBrowser(e->size()); } }
static LRESULT CALLBACK _WindowProcWebView(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_SIZE: { // Resize the browser object to fit the window ResizeBrowser(hwnd, LOWORD(lParam), HIWORD(lParam)); return(0); } case WM_CREATE: { // Embed the browser object into our host window. We need do this only // once. Note that the browser object will start calling some of our // IOleInPlaceFrame and IOleClientSite functions as soon as we start // calling browser object functions in EmbedBrowserObject(). if (EmbedBrowserObject(hwnd)) return(-1); // Another window created with an embedded browser object ++WindowCount; // Success return(0); } case WM_DESTROY: { // Detach the browser object from this window, and free resources. UnEmbedBrowserObject(hwnd); OleUninitialize(); // One less window --WindowCount; return(TRUE); } } return(DefWindowProc(hwnd, uMsg, wParam, lParam)); }