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 中显示红色波浪线
- STL 中有 dereference_iterator 吗? 2022-01-01
- 静态初始化顺序失败 2022-01-01
- 从python回调到c++的选项 2022-11-16
- 使用/clr 时出现 LNK2022 错误 2022-01-01
- 如何对自定义类的向量使用std::find()? 2022-11-07
- C++ 协变模板 2021-01-01
- 近似搜索的工作原理 2021-01-01
- Stroustrup 的 Simple_window.h 2022-01-01
- 与 int by int 相比,为什么执行 float by float 矩阵乘法更快? 2021-01-01
- 一起使用 MPI 和 OpenCV 时出现分段错误 2022-01-01