views:

415

answers:

1

I’m looking for a way to make red squiggly underlining in a Rich Edit control (I’m using version 4.1 with Msftedit.dll). I’m able to produce squiggly underlining with this code :

CHARFORMAT2 format;
format.cbSize = sizeof(format);
format.dwMask = CFM_UNDERLINETYPE;
format.bUnderlineType = CFU_UNDERLINEWAVE;
SendMessage(hWndEdit,EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&format);

The MSDN documentation doesn’t specify how to change the color of underlines, just the text (with underlines) and the text background. I’ve found some code that says to use the lower nibble for the underline type (CFU_UNDERLINEWAVE) and the upper one for color. So I’ve tried :

format.bUnderlineType = CFU_UNDERLINEWAVE | 0x50;

But that doesn't work.

UPDATE

I've tested this code with version 3.0 (Riched20.dll) and it's working. So the problem lies in 4.1. Was the feature removed or moved elsewhere ?

It's not working in version 6 (the dll used by office 2007) also.

A: 

I'm sorry to say this, but if changing the color of the underline is not documented by Microsoft you should not use it. Undocumented featured like this are subject to be removed in later versions, which might have happened here.

Your best bet is to ask Microsoft.

Dan Cristoloveanu