You could intercept the EN_UPDATE instruction and re-format the text when you receive that? Only problem with this is that you don't know what new data has been added.
You may, though, find it easier to override the CRichEditCtrl with your own and intercept whichevere messages you want do processing on the incoming data and then call the parent class's implementation of that function. That way everytime something is added you are performing the necessary re-formats ...
Edit: To derive a class from CRichEditCtrl is pretty easy
class CMyRichEditCtrl : public CRicheditCtrl
{
DECLARE_DYNAMIC( CMyRichEditCtrl )
protected:
DECLARE_MESSAGE_MAP()
public:
CMyRichEditCtrl();
virtual ~CMyRichEditCtrl();
// ... Rest of implementation here
};
You can then intercept messages in the message map as follows...
ON_MESSAGE( EM_PASTESPECIAL, &CMyRichEditCtrl::OnPasteSpecial )
and your handler will look like this:
LRESULT CMyRichEditCtrl::OnPasteSpecial( WPARAM wParam, LPARAM lParam )
wParam is the clipboard format and lParam contains either a NULL or a REPASTESPECIAL structure.
All you then need to do is make sure YOUR class is the one that receives all the messages and that can, easily be done, using the DoDataExchange function.
Define your member variable as:
CMyRichEditCtrl m_MyRichEditCtrl;
and add the following to DoDataExchange:
DDX_Control( pDX, IDC_MYRICHEDIT, m_MyRichEditCtrl );
All messages will now route through your implementation of the RichEditCtrl
You can intercept any message, including WM_PASTE, this way ...