Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

Resizing WebView2 browser content doesn't work 21 Dec 2022 21:36 #24852

  • ic2
  • ic2's Avatar
  • Topic Author


  • Posts: 1608
  • 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
    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: github.com/MicrosoftEdge/WebView2Feedback/issues/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

    Please Log in or Create an account to join the conversation.

    Last edit: by ic2.

    Resizing WebView2 browser content doesn't work 22 Dec 2022 08:17 #24854

    • Chris
    • Chris's Avatar


  • Posts: 3844
  • 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.
    XSharp Development Team
    chris(at)xsharp.eu

    Please Log in or Create an account to join the conversation.

    Resizing WebView2 browser content doesn't work 22 Dec 2022 12:32 #24857

    • ic2
    • ic2's Avatar
    • Topic Author


  • Posts: 1608
  • 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

    Please Log in or Create an account to join the conversation.

    • Page:
    • 1