Just, I would like to show you a clue between several methods.
CHARFORMAT cf;
CString text;
GetDlgItemText(IDC_RICHEDIT21, text);
//loop for all text in rich edit control
for(int i = 0; i < text.GetLength(); i++)
{
m_rich->SetSel(0 + i, i + 1); //from start to end character
m_rich->GetSelectionCharFormat(cf);
if(cf.dwEffects & CFE_UNDERLINE) //check whether underline character
{
//get underline character using GetSelText() etc.
}
}
However, this code does not concern any aspect of performance, so if there are many string and underlined characters in rich edit control, you have to check execute time, etc. Also, I think xMRi's reply is basic and correct method.
I would like to recommend below articles, also.