DaveCamp の回答を拡張すると、CHARFORMAT2W
構造にはbReserved1
エントリが含まれていました。
typedef struct _charformat2w
{
UINT cbSize;
DWORD dwMask;
DWORD dwEffects;
...
BYTE bReserved1;
} CHARFORMAT2W;
しかし、最新 (8.0) の SDK を見ると、bReserved1
エントリにunderline colorが追加されています。
typedef struct _charformat2w
{
UINT cbSize;
DWORD dwMask;
DWORD dwEffects;
...
#if (_RICHEDIT_VER >= 0x0800)
BYTE bUnderlineColor; // Underline color
#endif
} CHARFORMAT2W;
これは、Widows 8 の機能として定義されています ( _RICHEDIT_VER >= 0x0800
)。
下線の色を設定する方法は、デイブの答えです。
CHARFORMAT2 format;
format.cbSize = sizeof(format);
format.dwMask = CFM_UNDERLINETYPE | CFM_UNDERLINE;
format.dwEffects = CFE_UNDERLINE;
format.bUnderlineType = CFU_UNDERLINEWAVE;
format.bUnderlineColor = 0x05;
SendMessage(hWndEdit,EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM) &format);
残りのトリックは、色のBYTE
値です。まだ文書化されていませんが、16 色があります。
UnderlineColor_Black = 0x00;
UnderlineColor_Blue = 0x01;
UnderlineColor_Aqua = 0x02;
UnderlineColor_Lime = 0x03;
UnderlineColor_Fuchsia = 0x04;
UnderlineColor_Red = 0x05;
UnderlineColor_Yellow = 0x06;
UnderlineColor_White = 0x07;
UnderlineColor_Navy = 0x08;
UnderlineColor_Teal = 0x09;
UnderlineColor_Green = 0x0A;
UnderlineColor_Purple = 0x0B;
UnderlineColor_Maroon = 0x0C;
UnderlineColor_Olive = 0x0D;
UnderlineColor_DkGray = 0x0E;
UnderlineColor_LtGray = 0x0F;

編集: 色の名前を から に変更しCyan
ましたAqua
。の綴りを修正Fuchsia
。
注: パブリック ドメインにリリースされたすべてのコード。帰属は必要ありません。