Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.
Get IHTMLDocument and OleObject
Get IHTMLDocument and OleObject
Hello everyone,
is there by any chance a method to get from the browser IHTMLDocument and OleObject?
is there by any chance a method to get from the browser IHTMLDocument and OleObject?
- salvadordf
- Posts: 4082
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Get IHTMLDocument and OleObject
Hi,
IHTMLDocument is only available in TWebBrowser when it's configured to use Internet Explorer.
WebView2 doesn't have IHTMLDocument and you can only access the DOM using JavaScript at this moment.
IHTMLDocument is only available in TWebBrowser when it's configured to use Internet Explorer.
WebView2 doesn't have IHTMLDocument and you can only access the DOM using JavaScript at this moment.
Re: Get IHTMLDocument and OleObject
Thank you for your reply!
In my old browser I had a code like this:
I can't find an alternative ...
In my old browser I had a code like this:
Code: Select all
IDispatch* pHtmlDoc = m_browser.get_Document();
CComPtr<IHTMLDocument2> pHtmlDocument2;
pHtmlDoc->QueryInterface(IID_IHTMLDocument2, (void**)&pHtmlDocument2));
CComPtr<IViewObject2> pViewObject;
pHtmlDocument2->QueryInterface(IID_IViewObject2, (void **)&pViewObject));
- salvadordf
- Posts: 4082
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Get IHTMLDocument and OleObject
Chromium based browsers have a much different API than Internet Explorer.
Read this for more details :
https://learn.microsoft.com/en-us/microsoft-edge/webview2/
https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/?view=webview2-1.0.1518.46
What do you want to do with pViewObject, pHtmlDocument2 and pHtmlDoc ?
Read this for more details :
https://learn.microsoft.com/en-us/microsoft-edge/webview2/
https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/?view=webview2-1.0.1518.46
What do you want to do with pViewObject, pHtmlDocument2 and pHtmlDoc ?
Re: Get IHTMLDocument and OleObject
I need to draw content above the browser window
DC is HDC and cr is RECT.
Code: Select all
OleDraw(pViewObject.m_Obj, DVASPECT_CONTENT, DC, &cr);
- salvadordf
- Posts: 4082
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Get IHTMLDocument and OleObject
The WebView2 API doesn't expose any interface to draw over the browser but you can try a browser in "Windowless mode" and create a "Visual" over the browser.
The Windowless mode uses the DirectComposition API :
https://docs.microsoft.com/en-us/windows/win32/directcomp/directcomposition-portal
Check the WindowlessBrowser demo to see it working. I still have to fix some scaling issues in that demo when it runs in high DPI monitors.
The Windowless mode uses the DirectComposition API :
https://docs.microsoft.com/en-us/windows/win32/directcomp/directcomposition-portal
Check the WindowlessBrowser demo to see it working. I still have to fix some scaling issues in that demo when it runs in high DPI monitors.
Re: Get IHTMLDocument and OleObject
I am still struggling with this problem.
I have tried this code. But I still can't solve it.. Would you have any advice?
I've tried looking at 'WindowlessBrowser' but that's not what I'm looking for....
I have tried this code. But I still can't solve it.. Would you have any advice?
Code: Select all
"ICoreWebView2 * aWebView" //TO SHOW WHAT TYPE IT IS
IUnknown* oleObject = NULL;
hr = aWebView->QueryInterface(IID_PPV_ARGS(&oleObject));
if (SUCCEEDED(hr)) {
RECT clientRect = { 0 };
::GetClientRect(HWND, &clientRect);
HDC hdc = ::GetDC(HWND);
OleDraw(oleObject, DVASPECT_CONTENT, hdc, &clientRect);
::ReleaseDC(HWND, hdc);
I've tried looking at 'WindowlessBrowser' but that's not what I'm looking for....
- salvadordf
- Posts: 4082
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Get IHTMLDocument and OleObject
WebView2 doesn't support a pure "off-screen rendering mode" like CEF.
As far as I know, the only way to draw over a WebView2 browser is using the "Windowless mode".
As far as I know, the only way to draw over a WebView2 browser is using the "Windowless mode".
Re: Get IHTMLDocument and OleObject
Perfect thank you very much