Change highlight color of selected text in RichEdit

狂风中的少年 提交于 2019-12-21 22:00:53

问题


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.

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.


回答1:


Simply subclass it (posted a long time ago on google groups, C/Winapi code)



来源:https://stackoverflow.com/questions/1139234/change-highlight-color-of-selected-text-in-richedit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!