如何在 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
相关文章