识别Web浏览器的垂直滚动在C#中的最后位置到达
作者:互联网
我已经在Winforms的WebBrowser控件中加载了HTML内容.我想在最后一个位置达到垂直滚动时附加另一个HTML内容.因此,我坚持如何实现它.
这是我的示例代码:
WebBrowser web = new WebBrowser();
web.Document.Write("Some html content");
web.Document.Window.AttachEventHandler("onscroll", OnScrollEventHandler); // Create scroll event for browser control
private void OnScrollEventHandler(object sender, EventArgs e)
{
// Identify vertical scroll reached on last position and append another HTML
}
提前致谢.
解决方法:
这会起作用
class KeyHandle
{
private static Int32 WM_KEYDOWN = 0x100;
private static Int32 WM_KEYUP = 0x101;
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("user32.dll", SetLastError = true)]
static extern bool PostMessage(IntPtr hWnd, int Msg,
System.Windows.Forms.Keys wParam, int lParam);
public static void SendKey(IntPtr hWnd, System.Windows.Forms.Keys key)
{
PostMessage(hWnd, WM_KEYDOWN, key, 0);
}
}
调用方式:
KeyHandle.SendKey(this.webBrowser.Handle, Keys.PageDown);
标签:webbrowser-control,c,net,user-interface,winforms 来源: https://codeday.me/bug/20191108/2008915.html