如何在TWebBrowser中捕获页面区域?
我正在尝试制作一个程序,该程序可以对加载到 TWebBrowser
组件内的网站上的各个区域进行屏幕截图。
到目前为止,我只找到了“如何制作整个页面的屏幕截图”的解决方案,但我无法让它捕获特定区域,它只是向任何方向拉伸页面。
http://www.delphifaq.com/faq/f408.shtml
我一直在使用上面网站中提供的代码。
有没有办法修改代码,使其能够满足我的需要?我尝试过,但失败了。
如果有人至少能给我一个如何解决这个问题的指导,我将不胜感激。
谢谢
I am trying to make a program which would make screenshots of various areas on the site that is loaded inside TWebBrowser
component.
So far i have found only solutions to 'how to make screenshot of the whole page', but i just could not make it work to capture specific region, it just stretches the page in whatever direction.
http://www.delphifaq.com/faq/f408.shtml
I have been using the code presented in the site above.
Is there a way to modify the code so it would do what i need? I tried but i failed.
I would appreciate if anybody could at least give me a direction to how to solve this.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我建议改用 HTML Elemwnt 的
IHTMLElementRender
接口。您可以轻松找到光标下的元素并将其渲染为位图。在我的 TWebBrowser descant 中,我是这样实现的:
I recommend to use the
IHTMLElementRender
interface of the HTML Elemwnt instead. You can easily find the element under the cursor and render this to a bitmap.In my TWebBrowser descant I implemented it like this:
您可以使用 sourceBitmap.Canvas.CopyRect
You can use sourceBitmap.Canvas.CopyRect
您是否尝试过将
sourceDrawRect
设置为一个矩形,其顶部和左侧为负,右侧和底部超过您让视图对象绘制的位图的宽度和高度,以便您想要的区域落在此上位图?Have you tried setting
sourceDrawRect
to a rectangle with negative top and left, and a right and bottom past the width and height of the bitmap you let the viewobject draw onto, so that the region you want falls onto this bitmap?