Advertisement
Guest User

Untitled

a guest
Aug 8th, 2022
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.88 KB | None | 0 0
  1. using Microsoft.Web.WebView2.Wpf;
  2.  
  3. namespace WinFormsApp1.ext;
  4.  
  5. public partial class Window : Form
  6. {
  7.     private String name = "Undefined";
  8.     private String text = "Undefined";
  9.     private String url = "";
  10.     public Microsoft.Web.WebView2.WinForms.WebView2 webView21;
  11.     public Window(String title, String url, int width = 800, int height = 600)
  12.     {
  13.         this.url = url;
  14.         this.webView21 = new Microsoft.Web.WebView2.WinForms.WebView2();
  15.         this.webView21.Source = new Uri(this.url);
  16.         this.webView21.Size = new System.Drawing.Size(800, 600);
  17.         this.Controls.Add(this.webView21);
  18.         this.Text = title;
  19.         this.name = title;
  20.         this.Size = new System.Drawing.Size(800, 600);
  21.         this.Resize += onResize;
  22.     }
  23.  
  24.     private void onResize(object sender, EventArgs e)
  25.     {
  26.         this.webView21.Size = this.Size;
  27.     }
  28.  
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement