Question

In my Delphi program I want to display some information generated by the application. Nothing fancy, just 2 columns of text with parts of words color-coded.
I think I basically have two options:

  1. HTML in a TWebbrowser
  2. RTF in a TRichEdit.

HTML is more standard, but seems to load slower, and I had to deal with The Annoying Click Sound. Is RTF still a good alternative these days?

edit:
Good question from dangph: "What happens to the generated documents?"
The documents will be discarded after viewing.

Was it helpful?

Solution

I'd also use HTML. Besides, you just got an answer for the clicking sound in TWebBrowser.

If you'd rather not use TWebBrowser, take a look at Dave Baldwin's free HTML Display Components.

OTHER TIPS

I would vote for HTML.

I think it is more future oriented. The speed would not concern me.

The question of HTML or RTF may be irrelevant. If they are just used for display purposes, then the file format doesn't matter. It's really just an internal representation. (Are any files even being saved to disk?) I think the question to ask is which one solves the problem with the least amount of work.

I would be slightly concerned that the browser control is changing all the time. I doubt the richedit control will change much. I would lean towards the richedit control because I think there is less that could go wrong with it. But it's probably not a big deal either way.

Have you considered doing an ownerdraw TListView?

I would vote for HTML, too.

We started an app a while ago... We wanted to

display some information generated by the application. Nothing fancy, just...

(do you hear the bells ring???)

Then we wanted to display more information and style it even more.... ...someone decided, that RTF isn't enough anymore, but for backwards compatibility we moved on to MS Word over OLE-Server. That was the end of talking about performance anymore.

I think if we would have done that in HTML it would be much faster now.

RTF is much easier to deal with, as the TRichEdit control is part of every single Windows installation, and has much less overhead than TWebBrowser (which is basically embedding an ActiveX version of Internet Explorer into your app).

TRichEdit is also much easier to use to programmatically add text and formatting. Using the SelStart and SelLength, along with the text Attributes, makes adding bolding and italics, setting different fonts, etc. simple. And, as Re0sless said, TRichEdit can easily be printed while TWebBrowser makes it more complicated to do so.

I would vote RTF as I dont like the fact TWebBrowser uses Internet explorer, as we have had trouble with this in the past on tightly locked down computers.

Also TRichEdit has a print method build in, where as you have to do all sorts of messing about to get the TWebBrowser to print.

Nobody seems to have mentioned a reporting component yet. Yes, it is overkill right now, but if you use it anyway (and maybe you already have got some reporting to do in your app, so the component is already included) you can just display the preview and allow to print / export to pdf later, if it makes any sense. Also if you later decide that you want to have a fancier display there is nothing holding you back.

If both HTML and RTF won't satisfy your need, you could also use an open source text/edit component that supports coloring words or create your own edit component based on a Delphi component.

Another alternative to the HTML browser is the "Embedded Web Browser" components which I used a few projects for displaying html documents to the user. You have complete control over the embedded browser, and I don't recall any clicks when a page is loaded.

I vote for HTML also

RTF is good only for its editor, else then you'd better go standard.

RTF offers some useful text editing options like horizontal tabulator which are not available in HTML. Automatic hyperlink detection is also a nice extra. But I think I would prefer HTML, if these features are not required.

I vote for HTML.

  • Easier to generate programmatically.
  • Widely supported.
  • Since you don't need WYSIWYG capabilities I think HTML advantages trump RTF. Moreover, should the need to export generated data for further, WP-like editing arise, remember that major word processor can open and convert HTML files.

Use HTML, but with 'Delphi Wrapper for Chromium Embedded' by Henri Gourvest , Chromium embedded uses the core that powers Google Chrome.

Don't use TWebBrowser, I'm suffering from all programs that use IE's web control - the font is too small on my 22' monitor with a 1920x1080 resolution, I use Windows 7 and my system's DPI is 150% (XP mode), I tried everything to tweak trying to fix that, no luck...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top