选择HTML文档的一部分 [英] Selection of part of HTML doc

查看:105
本文介绍了选择HTML文档的一部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Web浏览器对象(或Internet Explorer),用户可以通过执行鼠标拖动操作来选择html文档的一部分.然后可以将这部分内容发送到剪贴板.我想访问用户选择的选择,并在将其复制到剪贴板之前对其进行修改.有人可以帮忙吗?

感谢您提供有关剪贴板的信息,但这用处不大.

我需要从webbrowser对象访问选择.必须定义一个起点和终点,该起点和终点显示用户在之前选择的HTML文档部分,该部分到达剪贴板附近.由于Web浏览器将所选内容突出显示,因此它必须有权访问所选文档的一部分.我需要在应用程序中修改这些起点和终点.

有任何想法吗?

With a Web-Browser object (or Internet Explorer) the user can select a portion of the html document by doing a mouse drag operation. This portion can then be sent to the clipboard for instance. I want to access the selection the user has chosen and modify it before it is copied to the clipboard. Can anyone help with how to do this?

Thanks for the info about the clipboard but this is of little use.

I need to access the selection from the webbrowser object. Somewhere there must be a start and end point defined which shows the portion of the HTML document that the user has selected before it gets anywhere near the clipboard. Since the webbrowser shows the selection highlighted, it must have access to the portion of the document selected. It is those start and end points which I need to modify in my app.

Any ideas?

推荐答案

这并不容易.我可以用本地代码和C ++解释如何做到这一点,并且可以考虑如何使用P/Invoke与C#项目互操作.

首先,您可以为Windows函数编写一些代码以参与剪贴板查看器链.
在这里查看: http://msdn.microsoft.com/zh-我们/library/ms649016(v=vs.85).aspx#_win32_Example_of_a_Clipboard_Viewer [
您可以在编写完整的Windows功能时执行此操作. (您是否熟悉本机Windows编程的这一部分?否则,您需要学习它或忘记本主题.)如果这不是您的" Windows类,则需要使用窗口控件的实例.这更加棘手.

您需要编写一个新的Windows函数,该函数可以调用其他Windows函数(链接).现在,您需要使用Windows API GetWindowLongHWND和参数GWL_WNDPROC从浏览器控件的实例中提取现有的Windows函数.在处理所有Windows消息(剪贴板链拦截所需的消息除外)时,新"窗口函数应使用提取的旧"窗口函数.您需要使用Windows API SetWindowLong将您的新"窗口函数设置为参与该链的窗口,并且您的HWNDindex参数等于GWL_WNDPROC,并且要使用新"窗口函数的地址.

参见:
http://msdn.microsoft.com/en-us/library/ms633584 (v = vs.85).aspx [ http://msdn.microsoft.com/en-us/library/ms633591 (v = vs.85).aspx [ http://www.visualstudiodev. com/visual-studio-tools-for-office/intercept-wmcopy-message-in-excel-vsto-57106.shtml [ 即使Microsoft VSTO团队Geoff Darst的成员得出此结论是为了响应拦截剪贴板副本的问题在Excel中,这与系统的工作方式有关.使用剪贴板链的技巧可能不足以实现您的目标.在任何情况下,都需要付出很大的努力才能实现.

—SA
This is not easy. I can explain how to do it in native code and C++ and you can think how to inter-operate with you C# project using P/Invoke.

First of all, you can write some code for a windows function to participate in a clipboard viewer chain.
Look here: http://msdn.microsoft.com/en-us/library/ms649016(v=vs.85).aspx#_win32_Example_of_a_Clipboard_Viewer[^], pay attention for the section "Example of a Clipboard Viewer".

You can do it when you''re writing full windows function. (Are you familiar with this part of native Windows programming? In not, you need to either learn about it or forget about the topic.) If this is not "your" windows class, you need to work with the instance of the windowed control. This is even more tricky.

You need to write a new windows function which can call some other windows function (chaining). Now, you need to extract existing windows function from the instance of your browser control using Windows API GetWindowLong using you HWND and the parameter GWL_WNDPROC. Your "new" windows function should use the extracted "old" windows function when processing all windows messages except those needed for Clipboard chain interception. You need to set you "new" windows function to the window participated in the chain using Windows API SetWindowLong, with your HWND, index parameter equals to GWL_WNDPROC and the address of your "new" windows function.

See:
http://msdn.microsoft.com/en-us/library/ms633584(v=vs.85).aspx[^],
http://msdn.microsoft.com/en-us/library/ms633591(v=vs.85).aspx[^].

Even when you do it all, you have limited opportunities.
Look here:
http://www.visualstudiodev.com/visual-studio-tools-for-office/intercept-wmcopy-message-in-excel-vsto-57106.shtml[^]:

"The only clipboard hooking mechanism provided by the operating system is the clipboard viewer chain. You can see what is put on the clipboard, but you can''t tell what applications are doing with it. You also have no way of knowing who updated the clipboard; you can only know that it changed."
Even though this conclusion by a member of Microsoft VSTO Team Geoff Darst was drawn in response to the question of intercepting clipboard copy in Excel, this is related to how system works. The trick of using clipboard chain may or may not be sufficient for your goals. In all cases, it will need a really good effort to achieve.

—SA


这篇关于选择HTML文档的一部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆