How to display Red Squiggly Lines in CRichEditCtrl in MFC(如何在 MFC 的 CRichEditCtrl 中显示红色波浪线)
问题描述
我正在努力在 MFC 应用程序中实现拼写检查器.我想要做的是在拼写错误的单词下显示红线.
I am working on implementing spellchecker in an MFC application. What I want to do is display red lines under incorrectly spelled words.
我找到了一个示例,但它仅适用于简单的编辑框,因为它可以简单地使用编辑控件默认字体进行计算以绘制波浪线.但它不适用于丰富的编辑控件,因为在丰富的编辑控件中,不同的单词可能有不同的字体.在这种情况下,我发现的示例在不正确的位置画线.
I found one example where it is done but it works only for a simple edit box because it can simply use the edit controls default font for doing calculations to draw the squiggly lines. But it does not work for a rich edit control as in rich edit control it is possible that different words can have different fonts. In this case the example I found draws lines at incorrect places.
如果有人已经为 CRichEditCtrl 做过这个,请告诉我?(它必须处理富编辑控件中存在的任何字体/大小的文本.)
Please let me know if someone has already done this for CRichEditCtrl? (it must handle text of any font/size that is present in the rich edit control.)
谢谢,萨钦
推荐答案
CHARFORMAT2 format;
SecureZeroMemory(&format, sizeof(CHARFORMAT2));
format.cbSize = sizeof(CHARFORMAT2);
format.dwMask = CFM_UNDERLINE|CFM_UNDERLINETYPE;
format.dwEffects = CFE_UNDERLINE;
format.bUnderlineType = CFU_UNDERLINEWAVE | 0x50;
SendMessage(EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&format);
我希望这会在你的文本中得到下划线
I hope this will get the underline in your text
这篇关于如何在 MFC 的 CRichEditCtrl 中显示红色波浪线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 MFC 的 CRichEditCtrl 中显示红色波浪线
基础教程推荐
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
- 初始化列表*参数*评估顺序 2021-01-01
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
- CString 到 char* 2021-01-01
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
