IntPtr handle = webBrowser.Handle;
StringBuilder className = new StringBuilder(100);
while (className.ToString() != "Internet Explorer_Server") // The class control for the browser
{
handle = GetWindow(handle, 5); // Get a handle to the child window
GetClassName(handle, className, className.Capacity);
}
//handle 表示浏览器的句柄
Graphics g = Graphics.FromHwnd(handle);
IntPtr dc;
dc = g.GetHdc();//此时失败。
同样的代码在botton的click事件中执行是正确的。
StringBuilder className = new StringBuilder(100);
while (className.ToString() != "Internet Explorer_Server") // The class control for the browser
{
handle = GetWindow(handle, 5); // Get a handle to the child window
GetClassName(handle, className, className.Capacity);
}
//handle 表示浏览器的句柄
Graphics g = Graphics.FromHwnd(handle);
IntPtr dc;
dc = g.GetHdc();//此时失败。
同样的代码在botton的click事件中执行是正确的。
解决方案 »
- tabControl和dataGridView的问题(分少,希望帮忙)
- 一个对象能找到此单实例,另一个对象找不到此单实例;错误:无法访问名为"XYZ"的已处置对象
- c# 如何实现对数据库中的.jpg/.xls 等文件?
- 我把一个对象以MemoryStream的方式存到一个资源文件(.resx)中,我如何把其取出来?
- “求教往特定的EXECL模板下写数据的例子(源代码)急急急”
- 如何检查SOCKET的SEND过来的包是不是正确?
- C#怎么对编好的类进行调用
- 怎样学好C#
- 【正则相关】c#中只想对字符串匹配第一次出现
- 如何在ASP.NET环境写含有窗口和菜单的程序?
- winform的问题,大家帮帮忙
- 练习定义抽象类,基类,派生的一道题
你好,我在调试堆栈中看线程熟悉的时候 timer是处于ui线程空间的啊。求解。