09-24-2007, 11:23 AM
I have small code for highlighting the text.
m_ctlEdit.SendMessage(EM_EXSETSEL,0,(LPARAM)&cr);
CHARFORMAT2 cf;
memset(&cf,0,sizeof(cf));
cf.cbSize=sizeof(cf);
cf.dwMask=CFM_COLOR|CFM_BOLD|CFM_ITALIC|CFM_UNDERLINE|CFM_FACE|CFM_BACKCOLOR;
cf.crBackColor=GetSysColor(COLOR_WINDOW);
cf.crTextColor=GetSysColor(COLOR_WINDOWTEXT);
_tcscpy(cf.szFaceName,_T("Courier New"));
m_ctlEdit.SendMessage(EM_SETCHARFORMAT,SCF_SELECTION,(LPARAM)&cf);
But when i do this Undo/Redo operation is not working i.e ctrl Z. Instead of SCF_SELECTION if i use SCF_WORD it works fine. Where does the problem exist? Is it with SCF_SELECTION or my code?
m_ctlEdit.SendMessage(EM_EXSETSEL,0,(LPARAM)&cr);
CHARFORMAT2 cf;
memset(&cf,0,sizeof(cf));
cf.cbSize=sizeof(cf);
cf.dwMask=CFM_COLOR|CFM_BOLD|CFM_ITALIC|CFM_UNDERLINE|CFM_FACE|CFM_BACKCOLOR;
cf.crBackColor=GetSysColor(COLOR_WINDOW);
cf.crTextColor=GetSysColor(COLOR_WINDOWTEXT);
_tcscpy(cf.szFaceName,_T("Courier New"));
m_ctlEdit.SendMessage(EM_SETCHARFORMAT,SCF_SELECTION,(LPARAM)&cf);
But when i do this Undo/Redo operation is not working i.e ctrl Z. Instead of SCF_SELECTION if i use SCF_WORD it works fine. Where does the problem exist? Is it with SCF_SELECTION or my code?