Jump to content
David Schwartz

RTF components or simple RTF editor?

Recommended Posts

I'd like to find a simple RTF editor, like Notepad, but that lets you select fg and bg colors, fonts, styles, and so on. Not HTML.

 

Short of that, I'd like to find a library that I can use to build it. (I have TRichView myself, but it's for something I'm noodling with at work, and they won't pay for anything for that purpose.)

 

Any ideas?

 

 

Share this post


Link to post

Did you mean WordPad and not Notepad?

Notepad is for plain text and uses the same Windows control as the standard TMemo control.

WordPad is for RTF and uses the same Windows control as the standard TRichEdit control.

Share this post


Link to post

There are plenty of Delphi sample program using TRichEdit which is an RTF editor.

Share this post


Link to post

why not just use TRichEdit? On the other hand, TJvRichEdit of the JVCL package is an enhanced rich editor.

Share this post


Link to post

I'd choose SynEdit. Supports syntax highlighting, code folding and even completion.

I made my own SQL syntax highlighter based on a TRichEdit component but it seriously started to lag when the script was around 3000 lines (full parsing and recoloring needed 300 ms, which is way too noticeable when it runs after each keypress...).

Although I could have optimized the logic (move parsing to a BG thread, only recolor when a closer was entered, only parse changed lines, etc) I just pulled SynEdit from GitHub and I'm very happy with it ever since.

I don't like having a full package installed in my IDE for one project only, but seeing how smooth and fluid that implementation is compared to mine... well, it will stay forever, I suppose 🙂

Share this post


Link to post

I searched in Google for an example of something built with a TRichEdit in Delphi, but didn't have much luck. I know I've seen several over the years, but now when I want one, I can't seem to find one. I found a very cursory one from a guy in Italy, and all of the comments are in Italian. But even though it has a Load and Save function, it doesn't save or load RTF data. I did, however, figure that part out. 🙂

 

I do not need a full-featured word processor. I basically want to cannibalize parts of it for use in another application -- mostly font features so I can highlight things, change fonts and/or sizes, stuff like that.

Share this post


Link to post
3 hours ago, David Schwartz said:

I searched in Google for an example of something built with a TRichEdit in Delphi, but didn't have much luck.

If you need an example of what TRichEdit can do just run Wordpad.

If you need examples of how to do it read the help or Google it. There are hundreds of examples. If you have an older version of Delphi installed there's even a richedit example project.

 

I don't see the problem.

Share this post


Link to post

For such basic features as font/color styling TRichEdit is quite enough. Changing style of text fragments is several lines of code

Share this post


Link to post

I see that the Rich Edit control has "moved" - not sure if the old wrapper supports 4.1?
https://docs.microsoft.com/en-us/windows/win32/controls/about-rich-edit-controls

 

VERSIONS OF RICH EDIT
Rich Edit version DLL Window Class
1.0 Riched32.dll RICHEDIT_CLASS
2.0 Riched20.dll RICHEDIT_CLASS
3.0 Riched20.dll RICHEDIT_CLASS
4.1 Msftedit.dll MSFTEDIT_CLASS

Share this post


Link to post
34 minutes ago, Lars Fosdal said:

I see that the Rich Edit control has "moved" - not sure if the old wrapper supports 4.1?

I can't see how that is relevant. Just because new control versions are added doesn't mean the old ones stop working.

 

TRichEdit is a wrapper around the RICHEDIT20W window class (i.e. RICHED20.DLL). Override CreateParams to use another version if that's important.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×