![]() |
![]() ![]() ![]() |
acClipboard
|
function HasFormat(const FormatName: String): Boolean; overload;
|
function HasFormat(FormatIndex: Integer): Boolean; overload;
|
The HasFormat method determines if the clipboard contains a particular format. If HasFormat is True, the format is present; if False, the format is absent.
|
|
The acClipboard component keeps a list of available format names in the AvailableFormats property. If you need to get the format index by name you can use GetFormatIndex method, or GetFormatName to retrieve the name by index.
|
|
Some standard clipboard formats are listed below. However, there are many more clipboard formats provided by Windows, and custom formats can be registered. All are supported by HasFormat.
|
Value | Meaning
|
CF_TEXT | Plain text, with each line ending with a CR-LF combination. A null character identifies the end of the text.
|
CF_BITMAP | A Windows bitmap graphic
|
CF_METAFILEPICT | Windows metafile
|
CF_PICTURE | An object of type TPicture (VCL only)
|
CF_SYLK | Symbolic link
|
CF_DIF | Data interchange format
|
CF_TIFF | Tiff image
|
CF_OEMTEXT | OEM text
|
CF_DIB | DIB image
|
CF_PALETTE | Palette data
|
CF_PENDATA | Pen data
|
CF_RIFF | Riff audio data
|
CF_WAVE | Wav audio data
|
CF_UNICODETEXT | Unicode text
|
CF_ENHMETAFILE | Enhanced metafile image
|
CF_HDROP | File name(s)
|
CF_LOCALE | Locale descriptor
|
CF_OBJECT Any persistent object
|
procedure TacFormHelpEditor.acClipboard1Change(Sender: TObject);
|
begin
|
PasteTextItem.Enabled := acClipboard1.HasFormat(CF_TEXT);
|
// here is an alternative
|
PasteBitmapItem := acClipboard1.HasFormat('BITMAP'); // <-- you can specify format name as string
|
end;
|
|
procedure TForm1.GetUnicodeExample;
|
var
|
Str: String;
|
begin
|
with acClipboard1 do
|
if HasFormat(CF_UNICODETEXT) then
|
Str := GetString(CF_UNICODETEXT);
|
else
|
Str := '';
|
end;
|
Active, AvailableFormats, ClipboardBitmap, ClipboardFiles and ClipboardText properties;
|
Clear, GetString, PutString, GetStream, PutStream, GetFormatIndex and GetFormatName methods;
|
OnChange event.
|