gpt4 book ai didi

c++builder - TRichEdit 暂停/恢复撤销功能

转载 作者:行者123 更新时间:2023-12-04 04:30:15 26 4
gpt4 key购买 nike

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

编辑
我已经通过使用 ITextDocument 接口(interface)解决了这个问题。请看我下面的帖子。

最佳答案

好的,我解决了。

您必须使用 ITextDocument界面设置各种撤消模式。在此示例中 Script_EditTRichEdit控制。

#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.

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

关于c++builder - TRichEdit 暂停/恢复撤销功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21195367/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com