如何通过双击一个单词来突出显示所有重复的文本Notepad
?
当我选择内容中重复的单词时,我希望记事本在突出显示文本时表现得像记事本++。
我熟悉一些pInvoke
材料和概念。我的 C# 项目处理获取记事本实例、句柄等所需的所有进程。但我不知道如何将颜色发送回记事本编辑控件?
我需要的是你对此事的建议和路线图。我应该涵盖哪个主题才能实现这一目标?
提前致谢。
您不能对记事本执行此操作。记事本使用纯编辑控件,不支持彩色文本范围。您需要包装一个丰富的编辑控件来执行此操作(或使用 Notepad++ 所做的 Scintilla 编辑控件)。
This page here from MSDN seems exactly what you're looking for.
From MSDN: You can add different visual effects to the editor by creating Managed Extensibility Framework (MEF) component parts. This walkthrough shows how to highlight every occurrence of the current word in a text file. If a word occurs more than one time in a text file, and you position the caret in one occurrence, every occurrence is highlighted
This will guide you on how to create an application that when you highlight a word it will highlight all matching words in Blue.
If you're not looking for a full solution then the concept is there and it is explained well.