I am not sure whether OnCtlColor() gets invoked for this rich edit control since created dynamically. So one easiest way to do this is
1. Create a class called CMyRichEditCtrl derived from MFC CRichEditCtrl
2. Handle the WM_ENABLE message within this new class by overriding OnEnable() function
3. Inside the OnEnable() function check its parameter and change the background color accordingly(parameter indicates disable or enable)
4. Make the type of your m_oRichEditCtrl as CMyRichEditCtrl
5. Create the Rich edit control within the OnInitDialog() of your dialog class as below
m_oRichEditCtrl.Create( WS_CHILD|WS_VISIBLE|ES_MULTILINE,
CRect0,0,150,150),this,IDC_RICHEDIT );
m_oRichEditCtrl.SetWindowText("Hello");
6. Do not forget to comment CRichEditCtrl::OnEnable(bEnable); inside the OnEnable() function
If any clarification needed I can help