MicrosoftEdge / WebView2Feedback

Feedback and discussions about Microsoft Edge WebView2
https://aka.ms/webview2
452 stars 55 forks source link

ViewController not visible after change parent of owner control #2070

Open amancini opened 2 years ago

amancini commented 2 years ago

Hello, when I change the parent of the form that contains the WebView2 the ViewController goes into invisible state. Even calling Put_IsVisible to true or trying to re-assign the parent with Put_ParentWindow the problem is not solved

the environment used is Delphi (Embarcadero) and when you change a parent all the handles of the children are recreated.

to date the only workaround I have found is to re-create the webView, but in this case I lose all the various operations done on the previously loaded page ...

I am using the latest version of WebView2Loader.dll [1.0.1083.0] and the latest WebView2 Runtime [97.0.1072.55]

Best regards

champnic commented 2 years ago

Hey @amancini - I'm unfamiliar with using WebView2 in Delphi, but if it's recreating all of the window handles then it's possible that's screwing up the WebView2 part of the tree. If you wanted to, could you try removing the WebView2 from the tree temporarily, allow Delphi to do the change parent operation, and then insert the WebView2 back into the tree?

amancini commented 2 years ago

Hello @champnic , yes i used this workaround for work with WebView2 when change the parent, and it work; but why not working Put_ParentWindow after the creation of new handles ?

champnic commented 2 years ago

You should be able to change the parent generally speaking, but it's possible that Delphi environment is doing something to the WebView2 HWNDs further down the tree (below the "parent" level) that is screwing them up.

amancini commented 2 years ago

ok ... but with the old WebView (WebBrowser) I don't have these problems and a parent handle change shouldn't break the tree

champnic commented 2 years ago

The new WebView2 control is very different from the old WebBrowser control, both in abilities and architecture. There will naturally be different behaviors and issues that stems from these changes.

Do you have a sample app that repros the issue that we could take a look at?

amancini commented 2 years ago

yes I have attached the changes to the demo project of the library used to use the webView2 on delphi

I am attaching the issue of github https://github.com/salvadordf/WebView4Delphi/issues/13