xsharp.eu • Resizing WebView2 browser content doesn't work
Page 1 of 1

Resizing WebView2 browser content doesn't work

Posted: Wed Dec 21, 2022 8:36 pm
by ic2
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

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())	
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

Resizing WebView2 browser content doesn't work

Posted: Thu Dec 22, 2022 7:17 am
by Chris
Hi Dick,

We you don't just use a Win Form for this particular control, to makes things simpler? A VO window will always have one hitng or another not perfectly working when dealing with .Net controls.

Resizing WebView2 browser content doesn't work

Posted: Thu Dec 22, 2022 11:32 am
by ic2
I think that could be a good advise, especially since we can convert a VO form to a Winforms window.

Frank/I will let you know if it solved it (it must I'd say as I have a working Winforms version too).

Dick