// Helper static IOleObject **GetBrowserHandle(const HWND hwnd) { return (IOleObject **)GetWindowLongPtr(hwnd, GWL_USERDATA); } // To Show/Hide the embedded browser withOUT hiding the parent window void ShowBrowser(const HWND hwnd, const BOOL bShow) { IOleObject *browserObject; IOleClientSite *site; RECT rect; browserObject = *GetBrowserHandle(hwnd); if (bShow) { browserObject->lpVtbl->GetClientSite(browserObject, &site); GetClientRect(hwnd, &rect); browserObject->lpVtbl->DoVerb(browserObject, OLEIVERB_SHOW, NULL, site, -1, hwnd, &rect); } else { browserObject->lpVtbl->DoVerb(browserObject, OLEIVERB_HIDE, NULL, NULL, 0, NULL, NULL); } }
Programming Tips - Win32: hide an embedded web browser
Date: 2021feb12
OS: Windows
Platform: win32
Language: C
Q. Win32: hide an embedded web browser
A. The great project on Code Project
https://www.codeproject.com/Articles/3365/Embed-an-HTML-control-in-your-own-window-using-pla
Embed an HTML control in your own window using plain C
by Jeff Glatt
Shows how to embed a browser but not how to hide/show it.
It would be easy to do ::ShowWindow(SW_HIDE) on the parent window
but I had a requirement to only hide the browser.
After a few hours, I figured this out using OLE verbs.