FormatCount (C++)

From RAD Studio Code Examples
Jump to: navigation, search

Description

The following code adds each format on the Clipboard to ListBox1 when Button1 is clicked. For Formats to 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 include <Clipbrd.hpp> (C++).

Code

#include <clipbrd.hpp>
#include <memory>       //For STL auto_ptr class

void __fastcall TForm1::Button1Click(TObject *Sender)
{
  for(int i=0; i < Clipboard()->FormatCount;i++)
    ListBox1->Items->Add(IntToStr(Clipboard()->Formats[i]));
}

Uses