首页 > 解决方案 > MSHTML 编辑 - 更改文本选择颜色

问题描述

我在设计(编辑)模式下使用MSHTML(控制)。TWebBrowser我使用TEmbeddedWB但慢慢远离该组件并实现我自己的界面。When a block of text is selected, so when typing into the editor and then selecting a block of text it is in black color for the background color.

相反,我想使用蓝色。

我知道它与选择范围有关,但不确定如何在设计器模式下对其进行修改。下面的代码当然是不在设计模式下的。

    IHTMLSelectionObject currentSelection = document.selection;
    IHTMLTxtRange range = currentSelection.createRange() as IHTMLTxtRange;
    if (range != null)
        {
        range.execCommand("BackColor", false, "0000FF");
        }

有任何想法吗?我必须使用事件接收吗?或者也许QueryCommandValue?我尝试了一些HiliteColor没有成功的事情(根据 Mozilla 文档,Internet Explorer 不支持)。

我使用 C++ Builder 或 Delphi,但欢迎使用任何语言的代码示例,我可以(可能)翻译它。

标签: c++delphiwebbrowser-controlmshtmldesignmode

解决方案


推荐阅读