RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TClipboard.Formats Property

Provides indexed access to all the formats the clipboard contains.

Pascal
property Formats [Index: Integer]: Word;
C++
__property Word Formats[int Index];

Read Formats to determine what formats encode the information currently on the clipboard. Each format can be accessed by its position in the array. 

Usually, when an application copies or cuts something to the clipboard, it places it there in multiple formats. An application can place items of a particular format on the clipboard and retrieve items with a particular format from the clipboard if the format is in the Formats array. To find out if a particular format is available on the clipboard, use the HasFormat method. 

When reading information from the clipboard, use the Formats array to choose the best possible encoding for information that can be encoded in several ways. 

Before you can write information to the clipboard in a particular format, the format must be registered. To register a new format, use the RegisterClipboardFormat method of TPicture.  

Delphi Examples: 

 

{
FormatCount, Formats example
The following code adds each format on the Clipboard to ListBox1 when Button1 is clicked. Note: You will need to add Clipbrd to the uses clause (Delphi) or include <Clipbrd.hpp> (C++).
}

uses clipbrd;

procedure TForm1.Button1Click(Sender: TObject);
var
  I: Integer;
begin
  for I := 0 to Clipboard.FormatCount - 1 do
    ListBox1.Items.Add(IntToStr(Clipboard.Formats[I]));
end;

 

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!