简体   繁体   English

是否可以在Win32编辑控件中突出显示文本?

[英]Is it possible to highlight text in a Win32 edit control?

I am working on a Win32 program in which I load text files. 我正在开发一个Win32程序,我在其中加载文本文件。 Would it be possible to highlight a particular word that is being displayed in the edit box? 是否可以突出显示编辑框中显示的特定单词?

By highlight, I mean, something like changing the color of the text as in syntax highlighting. 突出显示,我的意思是,像语法高亮一样改变文本的颜色。

A standard Edit control does not support that. 标准的Edit控件不支持它。 Use a RichEdit control instead. 请改用RichEdit控件。 It supports applying font/color settings to a range of characters via the EM_SETCHARFORMAT message. 它支持通过EM_SETCHARFORMAT消息将字体/颜色设置应用于一系列字符。

The Iczelion tutorial shows an alternative way to EM_SETCHARFORMAT that seems more like what you are asking. Iczelion教程显示了另一种方式来EM_SETCHARFORMAT ,似乎更像是你的要求。 There are a few other ones. 还有一些其他的。 It was more common back when computers were slower, but just-in-time highlighting is the way to go. 当计算机速度较慢时更常见,但是即时突出显示是要走的路。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM