'In MFC Edit Control, calling SetWindowText in EN_UPDATE event handler makes ctrl+z functionality not working?

In MFC edit control I need to allow only 0 to 2147483647. For that if user tries to type value more than 2147483647, I need to reset the value to previously entered good value.

To handle this requirement I am calling SetWindowText in EN_UPDATE event handler which makes CTRL+Z (undo) functionality is not working?

I tried ReplaceSel function instead of SetWindowText that is also not helped in making CTRL+Z (undo) functionality working.

SetSel( 0, -1, true );
ReplaceSel( m_szGoodValue, true);

Please help me to make undo/redo functionality working



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source