Is there a way to suspend/resume the Undo recording in a TRichEdit control? Is there a message to send or a mode to set?
EDIT
I have solved it by using the ITextDocument interface. See my post below.
Okay I solved it.
You have to use the ITextDocument
interface to set the various undo modes. In this example Script_Edit
is a TRichEdit
control.
#include <Richole.h>
#include <Tom.h>
// Define the ITextDocument interface GUID
#define DEFINE_GUIDXXX(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
EXTERN_C const GUID CDECL name \
= { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } }
DEFINE_GUIDXXX(IID_ITextDocument,0x8CC497C0,0xA1DF,0x11CE,0x80,0x98,
0x00,0xAA,0x00,0x47,0xBE,0x5D);
IRichEditOle *IRich;
ITextDocument *IDoc;
// Get the IRichEditOle interface object
SendMessage(Script_Edit->Handle,EM_GETOLEINTERFACE,0,(LPARAM)&IRich);
// Get the ITextDocument interface
IRich->QueryInterface(IID_ITextDocument,(void**)&IDoc);
// Suspend the Undo recording
IDoc->Undo(tomSuspend,NULL);
... Do your stuff ...
// Resume the Undo recording
IDoc->Undo(tomResume,NULL);
// Release the interfaces
IDoc->Release();
IRich->Release();
The ITextDocument->Undo()
can be used with:
ITextDocument->Undo(tomFalse, NULL); //Prevents Undo and empties buffer.
ITextDocument->Undo(tomTrue, NULL); //Restarts Undo again.
ITextDocument->Undo(tomSuspend, NULL); //Suspends Undo.
ITextDocument->Undo(tomResume, NULL); //Resumes Undo.
I hope this can be useful to others too...