怎么消除Webbrowser控件切换时的闪烁
展开全部
解决方法如下:
从WebBrowser派生一个新类
构造函数中添加DocumentCompleted事件响应
相关代码:
C# code
[DllImport("user32.dll")]
protected static extern int GetWindowLong(int hwindow, int unindex);
[DllImport("user32.dll")]
protected static extern int CallWindowProc(int lpPrevWndFunc, int hWnd, int Msg, int wParam, int lParam);
[DllImport("user32.dll")]
protected static extern int SetWindowLong(int hwindow, int unindex, CallWindowProcDelegate lnewvalue);
public static int oldWindow = 0;
public const int GWL_WNDPROC = -4;
public delegate int CallWindowProcDelegate(int Wnd, int Msg, int WParam, int LParam);
public CallWindowProcDelegate MyCallWindowProc;
bool add = false;
void ExtendWebBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
if(add)
{ return; }
add = true;
FindWindow fw = new FindWindow(this.Handle, "Internet Explorer_Server");
IntPtr hIE = fw.FoundHandle;
if (hIE.ToInt32() != 0)
{
oldWindow = (int)GetWindowLong(hIE.ToInt32(), GWL_WNDPROC);
MyCallWindowProc = new CallWindowProcDelegate(WndProc);
SetWindowLong(hIE.ToInt32(), GWL_WNDPROC, MyCallWindowProc);
}
}
从WebBrowser派生一个新类
构造函数中添加DocumentCompleted事件响应
相关代码:
C# code
[DllImport("user32.dll")]
protected static extern int GetWindowLong(int hwindow, int unindex);
[DllImport("user32.dll")]
protected static extern int CallWindowProc(int lpPrevWndFunc, int hWnd, int Msg, int wParam, int lParam);
[DllImport("user32.dll")]
protected static extern int SetWindowLong(int hwindow, int unindex, CallWindowProcDelegate lnewvalue);
public static int oldWindow = 0;
public const int GWL_WNDPROC = -4;
public delegate int CallWindowProcDelegate(int Wnd, int Msg, int WParam, int LParam);
public CallWindowProcDelegate MyCallWindowProc;
bool add = false;
void ExtendWebBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
if(add)
{ return; }
add = true;
FindWindow fw = new FindWindow(this.Handle, "Internet Explorer_Server");
IntPtr hIE = fw.FoundHandle;
if (hIE.ToInt32() != 0)
{
oldWindow = (int)GetWindowLong(hIE.ToInt32(), GWL_WNDPROC);
MyCallWindowProc = new CallWindowProcDelegate(WndProc);
SetWindowLong(hIE.ToInt32(), GWL_WNDPROC, MyCallWindowProc);
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询