HTML 或 RTF 显示带有颜色编码单词的文本列

发布于 2024-07-14 11:56:17 字数 321 浏览 5 评论 0原文

在我的 Delphi 程序中,我想显示应用程序生成的一些信息。 没什么花哨的,只有 2 列文本,其中部分单词用颜色编码。
我想我基本上有两个选择:

  1. TWebbrowser 中的 HTML
  2. RTF 中的 TRichEdit。

HTML 更标准,但似乎加载速度较慢,而且我必须处理烦人的点击声。 如今 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?

Note: The documents will be discarded after viewing.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(12

欢你一世 2024-07-21 11:56:17

我会投票支持 HTML。

我认为它更面向未来。 速度不会让我担心。

I would vote for HTML.

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

想你只要分分秒秒 2024-07-21 11:56:17

HTML 或 RTF 的问题可能无关紧要。 如果它们只是用于显示目的,那么文件格式并不重要。 这实际上只是一个内部表示。 (是否有任何文件被保存到磁盘上?)我认为要问的问题是哪一个以最少的工作量解决了问题。

我有点担心浏览器控件一直在变化。 我怀疑 Richedit 控件会发生太大变化。 我倾向于使用 Richedit 控件,因为我认为它出问题的可能性较小。 但无论如何,这可能都不是什么大问题。

你有没有考虑过做一个ownerdraw TListView?

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?

披肩女神 2024-07-21 11:56:17

我也会使用 HTML。 此外,您刚刚得到了TWebBrowser 中的点击声音的答案。

如果您不想使用 TWebBrowser,请查看 Dave Baldwin 的免费 HTML 显示组件

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.

若水般的淡然安静女子 2024-07-21 11:56:17

我也会投票支持 HTML。

我们不久前启动了一个应用程序......
我们想要

显示应用程序生成的一些信息。 没什么特别的,只是...

(你听到铃声响起吗???)

然后我们想显示更多信息并设计更多......
...有人认为 RTF 已经不够了,但为了向后兼容,我们转向 OLE-Server 上的 MS Word。 关于性能的讨论到此结束。

我认为如果我们在 HTML 中做到这一点,现在会快得多。

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.

白日梦 2024-07-21 11:56:17

RTF 更容易处理,因为 TRichEdit 控件是每个 Windows 安装的一部分,并且比 TWebBrowser(基本上是将 ActiveX 版本的 Internet Explorer 嵌入到您的应用程序中)的开销要少得多。

TRichEdit 也更容易用于以编程方式添加文本和格式。 使用 SelStart 和 SelLength 以及文本属性,可以使添加粗体和斜体、设置不同字体等变得简单。 而且,正如 Re0sless 所说,TRichEdit 可以轻松打印,而 TWebBrowser 则使打印变得更加复杂。

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.

美人如玉 2024-07-21 11:56:17

我会投票 RTF,因为我不喜欢 TWebBrowser 使用 Internet Explorer,因为我们过去在严格锁定的计算机上遇到过这种问题。

TRichEdit 还内置了一个打印方法,您必须做各种乱七八糟的事情才能让 TWebBrowser 进行打印。

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.

浅忆流年 2024-07-21 11:56:17

似乎还没有人提到报告组件。 是的,现在它有点矫枉过正,但如果你无论如何使用它(也许你已经在你的应用程序中做了一些报告,所以该组件已经包含在内),你可以只显示预览并允许打印/导出为 pdf稍后,如果有任何意义的话。 此外,如果您后来决定想要一个更精美的显示器,也没有什么可以阻止您。

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.

叹沉浮 2024-07-21 11:56:17

如果 HTML 和 RTF 都不能满足您的需求,您还可以使用支持着色单词的开源文本/编辑组件,或者基于 Delphi 组件创建您自己的编辑组件。

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.

独﹏钓一江月 2024-07-21 11:56:17

HTML 浏览器的另一个替代方案是“嵌入式 Web 浏览器”组件,我在几个项目中使用过它用于向用户显示 html 文档。 您可以完全控制嵌入式浏览器,并且我不记得加载页面时有任何点击。

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.

久夏青 2024-07-21 11:56:17

我投票支持 HTML,

RTF 只对其编辑器有好处,否则你最好采用标准。

I vote for HTML also

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

似梦非梦 2024-07-21 11:56:17

我投票支持 HTML。

  • 更容易以编程方式生成。
  • 得到广泛支持。
  • 由于您不需要所见即所得功能,我认为 HTML 的优势胜过 RTF。 此外,如果需要导出生成的数据以进行进一步的类似 WP 的编辑,请记住主要的文字处理器可以打开和转换 HTML 文件。

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.
停滞 2024-07-21 11:56:17

使用 HTML,但使用“Delphi Wrapper for Chromium EmbeddedHenri Gourvest ,Chromium 嵌入式使用为 谷歌浏览器

不要使用 TWebBrowser,我正在遭受所有使用 IE 网页控件的程序的困扰 - 在我的分辨率为 1920x1080 的 22' 显示器上,字体太小,我使用 Windows 7,系统的 DPI 为 150%(XP 模式),我尝试了一切调整试图解决这个问题,但没有运气......

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文