views:

695

answers:

11
+6  Q: 

HTML or RTF?

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.

+10  A: 

I would vote for HTML.

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

Josef Sábl
About the click, see my accepted answer (http://stackoverflow.com/questions/613943/annoying-click-sound-in-twebbrowser/614290#614290)
stevenvh
+1  A: 

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.

schnaader
+6  A: 

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.

Bruce McGee
The Baldwin components is what we use, and make things much easier.
mj2008
I have also used Dave Baldwin's components with great success.
skamradt
+1 for Dave Baldwin's components - we use it in some areas, and a TWebBrowser in others, depending on need.
Gerry
I see those components: 1) Does not have full HTML 3.2/4 support. 2) Do not suppot any Delphi beyond 2006. For a better wrapped Web Browser controls see http://www.bsalsa.com/
ldsandon
+8  A: 

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?

dangph
@dangph: Using a view control instead was my first idea as well, but both RTF and HTML viewers do allow for copying of displayed data without additional work, which is a nice usability improvement. Agreed on the other points, +1.
mghie
+3  A: 

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.

Peter
+2  A: 

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.

Re0sless
+4  A: 

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.

Ken White
+1  A: 

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.

skamradt
A: 

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.

mjustin
+1  A: 

I vote for HTML also

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

Omar Abid
+1  A: 

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.

dummzeuch