如何让richedit不选择或突出显示?

发布于 2024-09-11 12:33:55 字数 88 浏览 2 评论 0原文

帮助我知道 Richedit 无法突出显示/禁用突出显示或文本选择?同时删除光标位置。该应用程序仅用于显示 rtf 文本而不是编辑,因此我不需要这些功能。在德尔福

help i wnted the richedit cannot be highlighted/ disable the hightlight or selection of text? also remove the cursor pos. the application is intended for display only the rtf text and not editing so i dont need those features. in delphi

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

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

发布评论

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

评论(4

小瓶盖 2024-09-18 12:33:56

您可以将 SelLength 属性设置为0 在 OnSelectionChange 事件中

procedure TForm1.RichEdit1SelectionChange(Sender: TObject);
begin
 TRichEdit(Sender).SelLength:=0;
end;

you can set the SelLength property to 0 in the OnSelectionChange event

procedure TForm1.RichEdit1SelectionChange(Sender: TObject);
begin
 TRichEdit(Sender).SelLength:=0;
end;
执笏见 2024-09-18 12:33:56

只是为了澄清 - 您肯定需要丰富的文本功能,例如颜色、大小等?并且您肯定希望禁止从您的控件中进行复制&粘贴到其他地方吗?真的是这样吗?

我建议您重写 TRichEdit 中的 OnMouseUp、OnSaveCLipboard、OnSelectionChange 以及继承的方法 GetSelTextBuf、CopyToClipboard、CutToClipboard、SelectAll .. 也许还有 Repaint、Update 等。

确定您想要什么 - 如果您可以在没有富文本功能的情况下生活,那么只需使用一些 TLabel 并以编程方式编写文本即可。

如果您必须拥有富文本,我会看到一些选择 - 为您的组件编写大量偶数处理程序,或者创建您自己的从 TRichEdit 派生的组件,这使得更容易在一个表单上拥有多个组件,或者查看像 Tori's 之类的网站看看其他人是否已经制作了这样的组件。

祝你好运。

Just to clarify - you definitely need rich text features, like color, size, etc? And you definitely want to forbid copy from your control & paste somewhere else? Is that it exactly?

I would suggest that you override OnMouseUp, OnSaveCLipboard, OnSelectionChange from TRichEdit and the inherited methods GetSelTextBuf, CopyToClipboard, CutToClipboard, SelectAll .. maybe Repaint, Update and a few more.

Be sure of what you want - if you can live without rich text features, then just use some TLabels and write the text programatically.

If you must have rich text I see a few choices - write a lot of even handlers for your componet, or create your own component derived from TRichEdit, which makes it easier to have sevaral of them on one form, or look at sites like Tori's and see if someone else already made such acomponent.

Good luck.

暮光沉寂 2024-09-18 12:33:56

您可以将 RichEdit 的 readonly 属性设置为 true - 这可以防止击键等。

You could set the readonly property of the RichEdit to be true - this prevents keystrokes, etc.

老娘不死你永远是小三 2024-09-18 12:33:56

您可以简单地禁用 RichEdit 以防止文本选择并隐藏文本光标:

RichEdit.Enabled := FALSE;

You can simply disable the RichEdit to prevent text selection and to hide the text cursor:

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