winform项目 在form1里面放一个webbrowser控件 3个textbox控件 1个button 1个timer控件然后代码如下
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;
using System.Runtime.InteropServices;namespace 学习项目
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//API
[DllImport("user32")]
private static extern IntPtr WindowFromPoint(int X, int Y); private void Form1_Load(object sender, EventArgs e)
{
timer1.Interval = 100;
timer1.Start();
}
private void timer1_Tick(object sender, EventArgs e)
{
textBox1.Text = WindowFromPoint(Cursor.Position.X, Cursor.Position.Y).ToString();
} private void button1_Click(object sender, EventArgs e)
{
textBox2.Text = webBrowser1.Handle.ToString();
}
}
}
问题:为什么通过把鼠标移动到webbrowser那里 显示的句柄和 webBrowser1.Handle 的句柄不一样?
如何取webbrowser的句柄?
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;
using System.Runtime.InteropServices;namespace 学习项目
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//API
[DllImport("user32")]
private static extern IntPtr WindowFromPoint(int X, int Y); private void Form1_Load(object sender, EventArgs e)
{
timer1.Interval = 100;
timer1.Start();
}
private void timer1_Tick(object sender, EventArgs e)
{
textBox1.Text = WindowFromPoint(Cursor.Position.X, Cursor.Position.Y).ToString();
} private void button1_Click(object sender, EventArgs e)
{
textBox2.Text = webBrowser1.Handle.ToString();
}
}
}
问题:为什么通过把鼠标移动到webbrowser那里 显示的句柄和 webBrowser1.Handle 的句柄不一样?
如何取webbrowser的句柄?
如果要获取Internet Explorer_Server窗口句柄,建议使用该贴中方法:
http://topic.csdn.net/u/20110613/19/feb74217-62bc-4560-89ae-d760266c4d85.html