TRichEdit 暂停/恢复撤销功能

Max*_*and 4 vcl c++builder undo-redo trichedit c++builder-xe5

有没有办法在 TRichEdit 控件中暂停/恢复撤消记录?是否有要发送的消息或要设置的模式?

编辑
我已经通过使用 ITextDocument 接口解决了它。看我下面的帖子。

Max*_*and 5

好的,我解决了。

您必须使用该ITextDocument界面来设置各种撤消模式。在这个例子中Script_Edit是一个TRichEdit控件。

#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();
Run Code Online (Sandbox Code Playgroud)

ITextDocument->Undo()可以用于:

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.
Run Code Online (Sandbox Code Playgroud)

我希望这对其他人也有用...