我已经在 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);
关于c# - 识别 Web 浏览器的垂直滚动到达 c# 中的最后位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52269273/