我已经在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);