有没有办法在TRichEdit控件中挂起/恢复撤消记录?是否有消息要发送或要设置模式?
编辑
我已经通过使用ITextDocument接口解决了它。见下面我的帖子
最佳答案
好吧,我解决了。
您必须使用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();
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.
我希望这对其他人也有用...