基本上,我想在彩色文本上方的地方更改标准 RichEdit 选择颜色。
我正在 RichEdit 控件中实现“突出显示”功能(如黄色标记)。 现在,当我在所选文本上应用突出显示时,视觉上没有任何变化,因为选择保留在原位并且覆盖了字符颜色。这很糟糕,因为用户应该得到一些视觉反馈,表明已应用高亮显示。
现在我已经妥协了 - 在执行“突出显示”命令后,我只是完全清除了选择。 But it would be ideal to have selection color different when it is above colored text.
我该怎么做?提前致谢!
最佳答案
文本选择的颜色设置为hardwired to the system selection color in RichEdit 2.0 and higher . In RichEdit 1.0, the selection color is generated by inversing the background color , 所以你有一些控制权,但如果你降级到 1.0,你将失去很多功能。
解决方法是安装进程范围的 Detour hook在 GetSysColor API 上。
RichTextBox 的 WPF4 版本中有一个 SelectionBrush 属性,可用于更改选择的外观。不确定您的项目要求是否允许您在对话框中承载 WPF 控件。
关于c++ - 如何在 RichEdit 控件中更改选择颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5895790/