09-24-2007, 12:10 PM
Rich edit control notifies parent about a format change as if it would be text change. Set event mask to 0, then restore.
Also restore current selection (before restoring event mask), or undo may not work well in some cases.
This is some code from QM source:
int mask=SendMessage(m_ctlEdit,EM_GETEVENTMASK,0,0);
SendMessage(m_ctlEdit,EM_SETEVENTMASK,0,0);
SendMessage(m_ctlEdit,EM_SETCHARFORMAT,SCF_SELECTION,&cf);
SendMessage(m_ctlEdit,EM_SETEVENTMASK,0,mask);Also restore current selection (before restoring event mask), or undo may not work well in some cases.
This is some code from QM source:
Send(RE, EM_EXGETSEL, 0, &rsel);
if(_n->visible && GetFocus()==RE) { focus=1; SetFocus(0); } //to prevent selection painting and autoscrolling
Send(RE, EM_SETEVENTMASK, 0, 0);
//removed code block that sets char format
Send(RE, EM_EMPTYUNDOBUFFER, 0, 0);
Send(RE, EM_EXSETSEL, 0, &rsel);
if(focus && !f.nofocus) SetFocus(RE);
Send(RE, EM_SETEVENTMASK, 0, mask);