I'm using a C# wrapper control similar to the WebBrowser control that contains the COM / unmanaged MSHTML control. I'm using this control in the edit mode which allows the user of the application to edit a a HTML document in a WYSIWYG manner.
我正在使用类似于包含COM /非托管MSHTML控件的WebBrowser控件的C#包装器控件。我在编辑模式下使用此控件,允许应用程序的用户以WYSIWYG方式编辑HTML文档。
This control manages it's own undo / redo stack.
该控件管理它自己的undo / redo堆栈。
How can I reset / clear it so that user will not be able to redo / undo changes to the content of the document, but only be able to edit it ?
如何重置/清除它以便用户无法重做/撤消对文档内容的更改,但只能编辑它?
1 个解决方案
#1
3
To clear the undo stack of MSHTML control you can use undo manager service.
When enabling and disabling the undo service, the undo stack is cleared. To extract the undo manager out of the Document object of MSHTML you need to use the IServiceProvider.
要清除MSHTML控件的撤消堆栈,可以使用撤消管理器服务。启用和禁用撤消服务时,将清除撤消堆栈。要从MSHTML的Document对象中提取撤消管理器,您需要使用IServiceProvider。
The solution to this is some thing like:
对此的解决方案是:
//Extract undo manager
if (m_undoManager == null)
{
IServiceProvider serviceProvider = Document as IServiceProvider;
Guid undoManagerGuid = typeof(IOleUndoManager).GUID;
Guid undoManagerGuid2 = typeof(IOleUndoManager).GUID;
IntPtr undoManagerPtr = ComSupport.NullIntPtr;
int hr = serviceProvider.QueryService(ref undoManagerGuid2, ref undoManagerGuid, out undoManagerPtr);
if ((hr == HRESULT.S_OK) && (undoManagerPtr != ComSupport.NullIntPtr))
{
m_undoManager = (IOleUndoManager)Marshal.GetObjectForIUnknown(undoManagerPtr);
Marshal.Release(undoManagerPtr);
}
}
//And to clear the stack
m_undoManager.Enable(true);
Application.DoEvents();
More detailed implementation and more information can be seen at:
更详细的实施和更多信息可以在以下网址看到:
http://postxing.net:8080/PostXING/tags/v1.1/PostXING.HtmlComponent/Html/
http://msdn.microsoft.com/en-us/library/ms678623(VS.85).aspx
#1
3
To clear the undo stack of MSHTML control you can use undo manager service.
When enabling and disabling the undo service, the undo stack is cleared. To extract the undo manager out of the Document object of MSHTML you need to use the IServiceProvider.
要清除MSHTML控件的撤消堆栈,可以使用撤消管理器服务。启用和禁用撤消服务时,将清除撤消堆栈。要从MSHTML的Document对象中提取撤消管理器,您需要使用IServiceProvider。
The solution to this is some thing like:
对此的解决方案是:
//Extract undo manager
if (m_undoManager == null)
{
IServiceProvider serviceProvider = Document as IServiceProvider;
Guid undoManagerGuid = typeof(IOleUndoManager).GUID;
Guid undoManagerGuid2 = typeof(IOleUndoManager).GUID;
IntPtr undoManagerPtr = ComSupport.NullIntPtr;
int hr = serviceProvider.QueryService(ref undoManagerGuid2, ref undoManagerGuid, out undoManagerPtr);
if ((hr == HRESULT.S_OK) && (undoManagerPtr != ComSupport.NullIntPtr))
{
m_undoManager = (IOleUndoManager)Marshal.GetObjectForIUnknown(undoManagerPtr);
Marshal.Release(undoManagerPtr);
}
}
//And to clear the stack
m_undoManager.Enable(true);
Application.DoEvents();
More detailed implementation and more information can be seen at:
更详细的实施和更多信息可以在以下网址看到:
http://postxing.net:8080/PostXING/tags/v1.1/PostXING.HtmlComponent/Html/
http://msdn.microsoft.com/en-us/library/ms678623(VS.85).aspx