clipboard HasFormat method
Return to Introduction  Previous page  Next page
Applies to
acClipboard  

Declaration
function HasFormat(const FormatName: String): Boolean; overload;  
function HasFormat(FormatIndex: Integer): Boolean; overload;  

Description
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.  
ValueMeaning  
CF_TEXTPlain text, with each line ending with a CR-LF combination. A null character identifies the end of the text.  
CF_BITMAPA Windows bitmap graphic  
CF_METAFILEPICTWindows metafile  
CF_PICTUREAn object of type TPicture (VCL only)  
CF_SYLKSymbolic link  
CF_DIFData interchange format  
CF_TIFFTiff image  
CF_OEMTEXTOEM text  
CF_DIBDIB image  
CF_PALETTEPalette data  
CF_PENDATAPen data  
CF_RIFFRiff audio data  
CF_WAVEWav audio data  
CF_UNICODETEXTUnicode text  
CF_ENHMETAFILEEnhanced metafile image  
CF_HDROPFile name(s)  
CF_LOCALELocale descriptor  
CF_OBJECT   Any persistent object  

Examples
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;  

See also
Active, AvailableFormats, ClipboardBitmap, ClipboardFiles and ClipboardText properties;  
Clear, GetString, PutString, GetStream, PutStream, GetFormatIndex and GetFormatName methods;  
OnChange event.