Author: Jonas Bilinkevicius
When I type into a TMemo and then press ctrl+Z as usual, the last change is
removed. But if I programmatically add text through memo1.seltext := 'newtext'; the
ctrl+Z does not work. Why is this and is there a workaround?
Answer:
That's the way MS designed the multiline edit control to work. There is no way to
tell it programmatically to save the current content to the undo buffer, you can
only tell it to clear the undo buffer or to undo the last operation.
A hack that may work to trick it into filling the undo buffer is this.
1 { ... }2 with memo1 do3 begin4 perform(WM_CHAR, 32, 0);
5 sellength := -1;
6 seltext := someText;
7 end;