Hi. I am trying to underline a certain word in a rich edit control, located in a Dialog Box. I understand that I should select the word by sending the EM_SETSEL message, and then format it with the EM_SETCHARFORMAT message using a CHARFORMAT structure. Whenever I call the SendMessage function for the EM_SETCHARFORMAT message, it fails and returns 0. I have searched the board and msdn and have failed to discern the problem. Any help is appreciated. Thank you in advance.
Code:
//format
CHARFORMAT cf;
ZeroMemory(&cf,sizeof(cf));
cf.cbSize=sizeof(cf);
lstrcpy(cf.szFaceName,"Arial");
/* cf.bCharSet=ANSI_CHARSET;
cf.bPitchAndFamily=FF_ROMAN;*/
cf.dwMask=CFM_UNDERLINE;
cf.dwEffects=CFE_UNDERLINE;
SetFocus(GetDlgItem(hdlg,IDC_BIBLIO2));
SendMessage(GetDlgItem(hdlg,IDC_BIBLIO2),EM_SETSEL,(WPARAM)pos1,(LPARAM)pos2);
if(SendMessage(GetDlgItem(hdlg,IDC_BIBLIO2),EM_SETCHARFORMAT,(WPARAM)SCF_WORD|SCF_SELECTION,(LPARAM)(CHARFORMAT FAR *)&cf)==0)
MessageBox(NULL,"ERROR","ERROR",MB_OK);