FormatCount (Delphi)

From RAD Studio Code Examples
Jump to: navigation, search

Description

When Button1 is clicked, the following code adds each format on the Clipboard to ListBox1. To make Formats work, something must be on the Clipboard. Load the Clipboard by doing a Paste in another window.

Note: You need to add Clipbrd to the uses clause (Delphi) or to include <Clipbrd.hpp> (C++).

Code

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;

Uses