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.

handle - Chrome_RenderWidgetHostHWND

Post Reply
Vaytl
Posts: 22
Joined: Tue Jan 04, 2022 12:52 pm

handle - Chrome_RenderWidgetHostHWND

Post by Vaytl »

Hello Salvadordf!
Tell me how can I get the handle of the active window with the class name "Chrome_RenderWidgetHostHWND"?
User avatar
salvadordf
Posts: 4079
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: handle - Chrome_RenderWidgetHostHWND

Post by salvadordf »

Hi,

TWVBrowserBase already has the code to find the window called "Chrome_RenderWidgetHostHWND" and all other windows created by WebView2.

TWVBrowserBase has 4 events to intercept the messages sent to those windows :
  • TWVBrowserBase.OnWidget0CompMsg
  • TWVBrowserBase.OnWidget1CompMsg
  • TWVBrowserBase.OnRenderCompMsg
  • TWVBrowserBase.OnD3DWindowCompMsg
I just uploaded a new version of WebView4Delphi to GitHub which exposes all these handles :
  • TWVBrowserBase.RenderCompHWND
  • TWVBrowserBase.Widget0CompHWND
  • TWVBrowserBase.Widget1CompHWND
  • TWVBrowserBase.D3DWindowCompHWND
Vaytl
Posts: 22
Joined: Tue Jan 04, 2022 12:52 pm

Re: handle - Chrome_RenderWidgetHostHWND

Post by Vaytl »

Greate.
Many thanks.
Vaytl
Posts: 22
Joined: Tue Jan 04, 2022 12:52 pm

Re: handle - Chrome_RenderWidgetHostHWND

Post by Vaytl »

Why do I get a blank image when trying to take a screenshot using these handles?
User avatar
salvadordf
Posts: 4079
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: handle - Chrome_RenderWidgetHostHWND

Post by salvadordf »

Try using the TWVBrowser.CapturePreview instead and implement the TWVBrowser.OnCapturePreviewCompleted event to get the image.

Capturing images using HWNDs usually fails when the hardware acceleration is enabled.
Vaytl
Posts: 22
Joined: Tue Jan 04, 2022 12:52 pm

Re: handle - Chrome_RenderWidgetHostHWND

Post by Vaytl »

It didn't work:

Code: Select all

  GlobalWebView2Loader.EnableGPU := false;
Screenshot works fine with Edge (Chrome_RenderWidgetHostHWND)
salvadordf wrote: Wed Aug 23, 2023 1:32 pm Try using the TWVBrowser.CapturePreview instead and implement the TWVBrowser.OnCapturePreviewCompleted event to get the image.
Could you provide an example? I can't figure out how to implement it.
User avatar
salvadordf
Posts: 4079
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: handle - Chrome_RenderWidgetHostHWND

Post by salvadordf »

Vaytl wrote: Wed Aug 23, 2023 6:46 pm
salvadordf wrote: Wed Aug 23, 2023 1:32 pm Try using the TWVBrowser.CapturePreview instead and implement the TWVBrowser.OnCapturePreviewCompleted event to get the image.
Could you provide an example? I can't figure out how to implement it.
The MiniBrowser demo has all the code here :
https://github.com/salvadordf/WebView4Delphi/blob/53325f5db15b71aed8fb0aa903b6e7d51174e94c/demos/Delphi_VCL/MiniBrowser/uMiniBrowser.pas#L181
https://github.com/salvadordf/WebView4Delphi/blob/53325f5db15b71aed8fb0aa903b6e7d51174e94c/demos/Delphi_VCL/MiniBrowser/uMiniBrowser.pas#L499
Post Reply