|
|
Windows Clipboard 1. Open Borland C++ Builder. 2. Place a Button on the form. 3. Place an Image on the form. 4. Place a Memo box on the form. 5. Double click Button1. 6. Type the following red code in the Button1Click function: //This is what the Button1Click function should look like: //NOTE: You also need to place this include at the top of the Unit1.cpp file: #include < vcl\Clipbrd.hpp > void __fastcall TForm1::Button1Click(TObject *Sender) { TClipboard *pCB = Clipboard(); if(pCB->HasFormat(CF_BITMAP)) { Graphics::TBitmap *pBitmap = new Graphics::TBitmap(); pBitmap->LoadFromClipboardFormat(CF_BITMAP, pCB->GetAsHandle(CF_BITMAP), 0); Image1->Canvas->Draw(0, 0, pBitmap); delete pBitmap; } else if(pCB->HasFormat(CF_TEXT)) { Memo1->Lines->Text = Clipboard()->AsText; } } //--------------------------------------------------------------------------- 8. Run the program, press the Button1. The contents of the Window Clipboard will be displayed using Image1 or Memo1. |