获取子窗口的屏幕截图
如果我有一个窗口的句柄,当新的子窗口出现时,如何截取它们的屏幕截图? 现在我有代码可以每隔 0.1 秒对 Windows 窗体进行一次屏幕截图。 当我单击下拉列表框时,后续的屏幕截图不包含它。 使用spy++,我可以看到创建了一个新的子窗口,但不确定如何确保它包含在我的屏幕截图中。 有人有可能包含子窗口的代码吗?
预先感谢,
鲍勃
If I have a handle to a window, how do I take a screenshot of any new child windows when they show up? Right now I have code that takes a screenshot every .1 seconds of a windows form. When I click on a drop down list box the subsequent screenshots do not include it. Using spy++ I can see that a new child window was created but not sure how to make sure it is included in my screenshots. Does anybody have any code that might include child windows?
Thanks in advance,
Bob
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,ComboBox 的下拉菜单是一个特殊的窗口,即 LISTBOX。 .NET 没有提供内置方法来获取它的句柄,您可以 P/Invoke SendMessage 并发送 CB_GETCOMBOBOXINFO 消息。 COMBOBOXINFO.hwndList 包含句柄。
请注意,还有其他控件具有这种行为,例如 DateTimePicker。 另请注意,窗口可能会超出表单的范围。
此线程中的代码 应该有助于获得正确的 P/Invoke。
Yes, the dropdown of a ComboBox is a special window, a LISTBOX. .NET doesn't provide a built-in way to get the handle for it, you can P/Invoke SendMessage and send the CB_GETCOMBOBOXINFO message. COMBOBOXINFO.hwndList contains the handle.
Note that there are other controls that behave that way, DateTimePicker for example. Also note that the window can extend beyond the bounds of your form.
The code in this thread should be helpful to get the P/Invoke right.