News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Richedit undo buffer

Started by minor28, May 25, 2010, 04:52:39 PM

Previous topic - Next topic

minor28

Hi,

You can empty richedit undo buffer with EM_EMPTYUNDOBUFFER and you can change the default number of actions with EM_SETUNDOLIMIT. But can anyone tell me how to change memory to achieve
Quote...must be enough available memory to accommodate the new number.
.

I want to save the undo buffer and restore it later. Anyone know how to get the pointer to the undo buffer. Is it through IStorage interface or some other richedit interface?

hutch--

I doubt it can be done, I have never seen the internal format of the undo in richedit 1 and 2/3 published and you can sure it is not just plain text.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

minor28

MSDN about EM_SETHANDLE:
QuoteRich Edit: The EM_SETHANDLE message is not supported. Rich edit controls do not store text as a simple array of characters.

No, I don't think it is plain text. I only want to put away data and restore it later. I will giv IStorage a try.

Thanks for your answer.

jj2007

I had the same idea some time ago and could not find anything. As Hutch writes, it is not documented, and that is a bad sign especially for this messy bunch of controls. Chasing bugs in RichEdit can be a nightmare...
Anyway,  if your method works, let me know :bg

joemc

I needed this myself for something. Tried for a long time.  Gave up.

gwapo

I believe RichEdit3 (and RichEdit4 in Windows 7) implements ITextDocument. However, you should be familiar on how COM/OLE operates to take advantage of its implementation.

Send EM_GETOLEINTERFACE to your RichEdit control to get a IRichEditOle instance pointer. Once you got a hold of IRichEditOle instance, call its IUnknown::QueryInterface function to get an instance of ITextDocument.

From the instance of your ITextDocument, you can Suspend/Resume Undo, Get the collection of Undo grouping, etc.

Anyway, ITextDocument implementation won't let you get a pointer to the Undo buffer as it is doing the Undo/Freeze thing separately from RichEdit control.

Further, other interfaces from Text Object Model might help you, read here: http://msdn.microsoft.com/en-us/library/bb787607%28v=VS.85%29.aspx


Cheers,

-chris



gwapo

Found this KB article on how to Suspend/Resume Undo using ITextDocument interface:
http://support.microsoft.com/kb/199852

HTH,

-chris

minor28

Thanks gwapo,

I have already read about richedit interfaces and the articals you mention. The problem is I don't quite understand what MSDN text means.

For example:
Quote
IStorage::CopyTo
Copies the entire contents of an open storage object to another storage object.

What is the meaning of "contents of an open storage". I have to try.

gwapo

Quote from: minor28 on May 26, 2010, 05:50:45 AM
What is the meaning of "contents of an open storage". I have to try.

Depending on your IStorage instance. "Contents of an open storage" is referring to the storage buffer of an IStorage implementation.

How did you get your IStorage?

minor28

I haven't got it. I tryed IRichEditOle::GetObject with flag REO_GETOBJ_PSTG. REOBJECT.pstg should hold a pointer to IStorage. It did not so I tryed IRichEditOle::GetObjectCount which give zero objects. What I mean is that I am not familiar with the vocabulary used in IRichEditOle and associated interfaces and methods.

hutch--

I think you are in trouble with what you are after, I have been using rich edit controls for about 15 years and I have never seen access at the undo capacity that can save and restore them. While an edit control is reasonably straight forward, the multi-level undo/redo buffer design is competitive technology and the vendors have little reason to share it around.

You certainly can manipulate the undo/redo levels while the edit control is running but I have never seen access to the underlying data that is created by the undo/redo capacity. It would certainly be useful if you could save and restore the undo levels but I would not hold my breath waiting for it to be made available.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

oex

I guess you could write your own but have little or no real experience with richedit control, I used it many years back and quickly gave up on it doing anything near what I wanted.... Patching it is probably the only way to go and you'll probably waste your time with future upgrades
We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv

minor28

Yes, I suppose I have to give up this idea.

Thanks anyway.

gwapo

Quote from: minor28 on May 26, 2010, 03:05:52 PM
Yes, I suppose I have to give up this idea.

Thanks anyway.

Well, MFC has a undo/redo framework that works well with RichEdit (CRichEditCtrl) control., maybe you may want to dissect how MFC is doing it.

Cheers,

-chris