1.引用COM:MicroSoft Internet Controls
2. 核心代码如下:
private void button2_Click(object sender, EventArgs e)
{
IWebBrowser2 axIWebBrowser2 =(IWebBrowser2) this.webBrowser1.ActiveXInstance; //关键代码
Zoom(axIWebBrowser2,150);
}
public void Zoom( IWebBrowser2 axIWebBrowser2,int factor)
{
object pvaIn = factor;
try
{
axIWebBrowser2.ExecWB(OLECMDID.OLECMDID_OPTICAL_ZOOM,
OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER,
ref pvaIn, IntPtr.Zero);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}