I have this class CMyRichEditCtrl
deriving from CRichEditCtrl
. I have the following:
void CMyRichEditCtrl::PreSubclassWindow()
{
CRichEditCtrl::PreSubclassWindow();
SetEventMask(GetEventMask() |ENM_CHANGE | ENM_SELCHANGE | ENM_MOUSEEVENTS | ENM_KEYEVENTS | ENM_PROTECTED);
CHARFORMAT format = { sizeof(CHARFORMAT) };
format.dwEffects = CFE_PROTECTED;
format.dwMask = CFM_PROTECTED;
SetDefaultCharFormat(format);
}
...
ON_NOTIFY_REFLECT(EN_PROTECTED, &CMyRichEditCtrl::OnProtected)
So the idea is the custom control will itself be notified when changes to the text are made (mainly I'm after clipboard messages).
I drop this class into existing dialogs, replacing existing edit controls. In some dialogs it works perfectly, but in others OnProtected is not fired.
Is there some setting on a parent dialog which might be causing this different bahaviour?
Update: Well I found one cause. In one dialog m_MyRichEdit.SetFont(...) is called. Apparently this un-protects the text, though I am not entirely sure why.