HTML or RTF to display columns of text with color-coded words
Asked Answered
A

12

8

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?

Note: The documents will be discarded after viewing.

Attica answered 5/3, 2009 at 10:59 Comment(3)
What about just using string grid (or other suitable grid component)?Goodwill
Not sure that's a good idea. With a stringgrid I would have to write a lot of code in OwnerDraw to get the formatting right (alignment, font, color). I might as well output text directly to a image's canvas. HTML and RTF take care of formatting.Attica
Ok, you weren't very specific about the data in question. I think report generators can also output to screen. They are made for more complex formatting.Goodwill
P
6

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.

Philcox answered 5/3, 2009 at 11:21 Comment(4)
The Baldwin components is what we use, and make things much easier.Cowpoke
I have also used Dave Baldwin's components with great success.Feudal
+1 for Dave Baldwin's components - we use it in some areas, and a TWebBrowser in others, depending on need.Blackford
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 bsalsa.comCagliari
I
13

I would vote for HTML.

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

Illness answered 5/3, 2009 at 11:6 Comment(1)
About the click, see my accepted answer (#614443)Attica
G
8

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?

Geryon answered 5/3, 2009 at 12:22 Comment(1)
@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.Ultun
P
6

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.

Philcox answered 5/3, 2009 at 11:21 Comment(4)
The Baldwin components is what we use, and make things much easier.Cowpoke
I have also used Dave Baldwin's components with great success.Feudal
+1 for Dave Baldwin's components - we use it in some areas, and a TWebBrowser in others, depending on need.Blackford
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 bsalsa.comCagliari
L
4

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.

Lierne answered 5/3, 2009 at 12:42 Comment(0)
H
4

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.

Hoke answered 5/3, 2009 at 16:3 Comment(0)
M
2

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.

Mixie answered 5/3, 2009 at 13:46 Comment(0)
M
2

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.

Modulus answered 17/1, 2010 at 12:13 Comment(1)
Most reporting components have exports to HTML and/or RTF. Just a matter of configuration.Cumulative
D
1

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.

Duet answered 5/3, 2009 at 11:7 Comment(0)
F
1

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.

Feudal answered 5/3, 2009 at 17:1 Comment(0)
E
1

I vote for HTML also

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

Elianore answered 21/3, 2009 at 18:21 Comment(0)
M
0

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.
Margoriemargot answered 16/11, 2011 at 8:24 Comment(0)
W
0

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...

Wizen answered 16/11, 2011 at 17:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.