在RichEdit中更改所选文本的高亮显示颜色 [英] Change highlight color of selected text in RichEdit
问题描述
如何在选择文本时更改RichEdit控件中选定文本的颜色?
How do I change the color of selected text in a RichEdit control, while the text is being selected? SetSysColor() can do it, but that changes the Highlight-color globally.
使用SCF_SELECTION设置CHARFORMAT2,并发送EM_SETCHARFORMAT,确实改变了字体和背景色。SetSysColor()可以做到这一点。但只有在您取消选择相同的范围后才会显示。
这不是真正有用的,因为我想要它是原来的颜色再次取消选择一次。
Setting a CHARFORMAT2 with SCF_SELECTION, and sending a EM_SETCHARFORMAT does change the font and background color. But is only visible once you deselect the same range. That's not really helpful, since I want it to be the original color again once something is deselected.
所以,它是怎么做的困惑我。
So, how it's really done puzzles me.
推荐答案
子类它(很久以前发布在google群组上,C / Winapi代码)
Simply subclass it (posted a long time ago on google groups, C/Winapi code)
这篇关于在RichEdit中更改所选文本的高亮显示颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!