Resizing WebView2 browser content doesn't work
Posted: Wed Dec 21, 2022 8:36 pm
In VO we have a window that shows an OLEWebbrowser in the right half, with OA_WIDTH_HEIGHT as Owner Alignment. It shows e.g. a PDF and if you enlarge the window, the PDF fills the full right half of the window.
In X# we replaced it with a custom control (called PreView), same Owner Alginment. It displays a PDF, when assigned, as well, but doesn't resize the PDF itself
It looks the same as in in this post to the WebView2 team: https://github.com/MicrosoftEdge/WebVie ... ssues/2411. If you browse to the pictures there, you see also there the webpage he displays doesn't resize. The team responds that they get it working in their Winforms program. I have both a Winforms program and a WPF based program in which resizing works fine too. I think I used a docking panel for it which the Dock property should do in this case. But it doesn't work in a VO form.
What did we miss?
Dick
In X# we replaced it with a custom control (called PreView), same Owner Alginment. It displays a PDF, when assigned, as well, but doesn't resize the PDF itself
Code: Select all
Protect webView As Microsoft.Web.WebView2.WinForms.WebView2
Self:webView := Microsoft.Web.WebView2.WinForms.WebView2{}
Self:webView:Visible := True
Self:webView:Location := System.Drawing.Point{1, 1}
Self:webView:Size := System.Drawing.Size{600,700} // This must be added otherwise nothing shows at all
self:webViewInkoop:Dock:=System.Windows.Forms.DockStyle.Fill
Self:WebView:AutoSize:=True
SetParent(Self:WebView:Handle, Self:oDCPreView:Handle())
What did we miss?
Dick