Only just started to look at the UNDO / REDO commands etc.
I have a right click option for "undo".
I make two changes, and the undo removes change number two, when I undo again it puts change number two back in again, that's what MS says it should do.
What I would like it to do is to undo change 2, then undo change 1...
Has anyone had a go at this, if so could you shed a little light on it for me please.
Thanks,
Andy.
I noticed you need to set these before a rich edit control has any text in:
SENDMESSAGE(w1.hWnd,EM_SETTEXTMODE,TM_MULTILEVELUNDO,0,1)
SENDMESSAGE(w1.hWnd,EM_SETUNDOLIMIT,100,0,1)
(1 is the rich edit control).
The above SENDMESSAGE's are the default rich edit settings.
I have tried this in my program and the rich edit example, in mine, it does what I previously said, in the example program an undo removes / restore multiple lines all at the same time....?
Forgot to mention the rich edit is sub classed like this:
SUB SubclassRichEdit(parent as WINDOW,id as INT)
hEdit = GETCONTROLHANDLE(parent,id)
lpfn = SetWindowLongA(hEdit,-4,&RichEditHandler)
SetPropA(hEdit,"edit_handler",lpfn)
RETURN
ENDSUB
nice info Andy.
I don't think I've ever used that in a rich edit.
Thanks Larry,
But even with these commands, both my program and the rich edit example do not work for multiple undo's.
Puzzled...
Andy.
Andy,
I believe the built-in richedit control is linked around richedit ver 1.0 (not sure about this). Microsoft implemented multilevel undo starting with 2.0.
https://docs.microsoft.com/en-us/windows/win32/controls/about-rich-edit-controls
No idea if you can change the version, if you can't you'll neeed to implement the richedit by yourself to get a newer version.
Thanks Fasecero,
It seems I have both version 1 and 2 (or could be 3) on my system.
I can use
UINT hInst=LoadLibrary("riched20.dll")
to load version 2 / 3, but what then? do I make a library file from it then add in $USE riched20.lib to my program?
If I have to make a lib file, can I distribute it with my program?
Help please!
Andy.
Andy,
You define the richedit version in 2 different places
1) when you choose the library, as you are doing
UINT hInst = LoadLibrary ("riched20.dll")
2) when you create the richedit, choosing the appropriate "window class" for CreateWindowEx
string RICHEDIT_CLASS
RICHEDIT_CLASS = "RichEdit" ' richedit 1.0
RICHEDIT_CLASS = "RichEdit20A" ' richedit 2.0
INT hwnd_richedit = CreateWindowEx (0, RICHEDIT_CLASS, ...)
I don't know which windows class iwbasic is currently using, but assuming multilevel undo isn't working it should be 1.0. In such a case to get multilevel undo working you would need to implement ALL the richedit 2.0 by yourself.
Fasecero,
Thanks for that, turns out I have version 1 and version 3.1.
This seems like it's a lot of work just to implement undo / redo.
If this is where I have to stop the editor now I will, or maybe I could use my own buffer to store changes? maybe?
If I call time on the editor (6 months + in) I will post all the lessons / do's ' don'ts / how to's in a tutorial, as I have spent a lot of time experimenting / reading documentation and learning how a rich edit actually works, which can be different than just what the documentation says!
Thanks again,
Andy.
Is there an easy way to tell which version of the RichEdit is available on a system? It seems I have riched20.dll and riched32.dll on my system, but could not find any other versions.
Bill
Found this table. If you have windows 10, chances are you have all versions.
Quote| Version | Class name | Library | Shipped with | New features
|------------|---------------|--------------|-----------------|
| 1.0 | "RICHEDIT" | Riched32.dll | Windows 95 |
| 2.0 | "RichEdit20W" | Riched20.dll | Windows 98 | ITextDocument
| 3.0 | "RichEdit20W" | Riched20.dll | Windows 2000 | ITextDocument2
| 3.1 | "RichEdit20W" | Riched20.dll | Server 2003 |
| 4.1 | "RICHEDIT50" | Msftedit.dll | Windows XP SP1 | tomApplyTmp
| 7.5 | "RICHEDIT50" | Msftedit.dll | Windows 8 | ITextDocument2 (new), ITextDocument2Old, Spell checking, Ink support, Office Math
| 8.5 | "RICHEDIT50" | Msftedit.dll | Windows 10 | LocaleName, more image formats
Interesting...
I have Msftedit.dll (version 4.1) so I tried to create a rich edit, it loads the dll but does not create the rich edit?
$INCLUDE "windowssdk.inc"
$INCLUDE "richedit.inc"
const TM_MULTILEVELUNDO = 8
const EM_SETTEXTMODE = (WM_USER + 89)
const EM_SETUNDOLIMIT = (WM_USER + 82)
UINT hInst = LoadLibrary ("Msftedit.dll")
string MSFTEDIT_CLASS = "RichEdit41A"
WINDOW w1
OPENWINDOW w1,0,0,500,400,@MINBOX|@MAXBOX|@SIZE|@CAPTION,0,"Window",&handler
int rHandle = CreateWindowEx(0,MSFTEDIT_CLASS,"",0x50B010C4,0,0,500,400,w1.hwnd,1,GetModuleHandle(0),0)
setcaption w1,str$(rHandle)
SENDMESSAGE(w1.hWnd,EM_SETTEXTMODE,TM_MULTILEVELUNDO,0,1)
SENDMESSAGE(w1.hWnd,EM_SETUNDOLIMIT,100,0,1)
SubclassRichEdit(w1,1)
And looking in the rich edit include file it mentions RICHEDIT50W?
Any ideas?
Thanks,
Andy.