我需要能够以编程方式上下滚动窗口,只给出屏幕上的一个点。我已经设法使用Windows API检索句柄,但我无法让它向上或向下滚动。
假设以下代码:
//retrieves the correct window.
IntPtr hWnd = Win32.WindowFromPoint(new Point(xPos, yPos));
Win32.Rect rect = default(Win32.Rect);
//retrieves a rectangle with the desired windows dimensions
Win32.GetWindowRect(hWnd, ref rect);
//Insert scroll code here...
答案 0 :(得分:4)
滚动窗口,您需要通过使用适当的参数调用SendMessage
向其发送Windows消息 - 有关滚动和相关消息等的完整详细信息,请参阅MSDN。
更新 - 根据评论:
另一种选择可能是在hWnd
上调用ScrollWindowEx
- 根据评论,不应使用调用ScrollwindowEx
,因为它会在显示的状态和内部状态之间产生不一致各自的窗口!
答案 1 :(得分:1)
您是否尝试将SendMessage()功能与WM_VSCROLL和WM_HSCROLL消息一起使用?
同时检查SetScrollInfo(pInvoked版本here)。即使是this帖子也可能对您有所帮助。