Resizing WebView2 browser content doesn't work

This forum is meant for questions and discussions about the X# language and tools
Post Reply
ic2
Posts: 1798
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

Resizing WebView2 browser content doesn't work

Post 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
User avatar
Chris
Posts: 4562
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Resizing WebView2 browser content doesn't work

Post 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.
Chris Pyrgas

XSharp Development Team test
chris(at)xsharp.eu
ic2
Posts: 1798
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

Resizing WebView2 browser content doesn't work

Post 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
Post Reply