- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
Embarcadero RAD Studio VCL 具有 TClipboard.HasFormat
方法,其用法例如Clipboard.HasFormat(CF_TEXT)
或 Clipboard.HasFormat(CF_BITMAP)
等..
但我没有找到任何支持的 CF_RTF
或 CF_RICHTEXT
格式描述符来指示剪贴板中的富文本格式。
因此,我在 Microsoft WordPad 中创建了一些格式化文本并将其复制到剪贴板。然后我使用剪贴板 spy 程序来检查剪贴板上的格式:
这里列出了 3 种 RichText 格式,其格式描述符为 C078、C16B 和 C1A5。
这些格式描述符是通用的还是依赖于单个系统或当前情况?即,我通常可以使用 Clipboard.HasFormat($C078)
来检测剪贴板上的任何 RichText 格式吗?或者还有其他方法吗?
最佳答案
Can I generally use
Clipboard.HasFormat($C078)
to detect any RichText format on the clipboard?
不可以,您需要通过RegisterClipboardFormat
注册RTF剪贴板格式功能。返回值由系统生成,可能会有所不同。
Registers a new clipboard format. This format can then be used as a valid clipboard format.
If a registered format with the specified name already exists, a new format is not registered and the return value identifies the existing format. This enables more than one application to copy and paste data using the same registered clipboard format.
var
CF_RTF: UINT;
...
initialization
CF_RTF := RegisterClipboardFormat('Rich Text Format');
然后检查:
if Clipboard.HasFormat(CF_RTF) then ...
{ or // if Windows.IsClipboardFormatAvailable(CF_RTF) then ... }
<小时/>
编辑:阅读文档后:How to Use Rich Edit Clipboard Operations
常量 CF_RTF
已在 RichEdit
单元中声明为:
CF_RTF = 'Rich Text Format';
CF_RTFNOOBJS = 'Rich Text Format Without Objects';
CF_RETEXTOBJ = 'RichEdit Text and Objects';
因此,对 RegisterClipboardFormat
的返回值使用其他命名可能是更好的主意。例如
uses RichEdit;
...
var
CF_RICHTEXT: UINT;
...
initialization
CF_RICHTEXT := RegisterClipboardFormat(RichEdit.CF_RTF);
并且:
if Clipboard.HasFormat(CF_RICHTEXT) then ...
注意:已经有一些保留系统剪贴板格式,例如 CF_TEXT
(=1)、CF_BITMAP
(=2) 等。 ..但“CF_RTF”或“CF_RICHTEXT”不是其中之一。它是 RICHEDIT
公共(public)控件使用的自定义格式,并通过 RegisterClipboardFormat
注册,如前所述。
关于delphi - 如何可靠地检测剪贴板上的 RITCHTEXT 格式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45837425/
Embarcadero RAD Studio VCL 具有 TClipboard.HasFormat 方法,其用法例如Clipboard.HasFormat(CF_TEXT) 或 Clipboard.
我是一名优秀的程序员,十分优秀!