using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Myfirstprogram
{
public partial class Client : Form
{
public Client()
{
InitializeComponent();
this.Load += new EventHandler(Client_Load);
webBrowser1.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webBrowser1_DocumentCompleted);
}
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
if (webBrowser1.ReadyState != WebBrowserReadyState.Complete) return;
Size szb = new Size(webBrowser1.Document.Body.OffsetRectangle.Width,
webBrowser1.Document.Body.OffsetRectangle.Height);
Size sz = webBrowser1.Size;
int xbili = (int)((float)sz.Width / (float)szb.Width * 100);//水平方向缩小比例
int ybili = (int)((float)sz.Height / (float)szb.Height * 100);//垂直方向缩小比例
webBrowser1.Document.Body.Style = "zoom:" + sz.ToString() + "%";//也可以直接设置
webBrowser1.Invalidate();
}
private void Client_Load(object sender, EventArgs e)
{
webBrowser1.Navigate("http://www.csdn.net/");
webBrowser1.ScriptErrorsSuppressed = false;
webBrowser1.ScrollBarsEnabled = false;
}
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Myfirstprogram
{
public partial class Client : Form
{
public Client()
{
InitializeComponent();
this.Load += new EventHandler(Client_Load);
webBrowser1.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webBrowser1_DocumentCompleted);
}
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
if (webBrowser1.ReadyState != WebBrowserReadyState.Complete) return;
Size szb = new Size(webBrowser1.Document.Body.OffsetRectangle.Width,
webBrowser1.Document.Body.OffsetRectangle.Height);
Size sz = webBrowser1.Size;
int xbili = (int)((float)sz.Width / (float)szb.Width * 100);//水平方向缩小比例
int ybili = (int)((float)sz.Height / (float)szb.Height * 100);//垂直方向缩小比例
webBrowser1.Document.Body.Style = "zoom:" + sz.ToString() + "%";//也可以直接设置
webBrowser1.Invalidate();
}
private void Client_Load(object sender, EventArgs e)
{
webBrowser1.Navigate("http://www.csdn.net/");
webBrowser1.ScriptErrorsSuppressed = false;
webBrowser1.ScrollBarsEnabled = false;
}
}
}