Programming C++Builder An example on how to use GetFormImage() and Assign() functions in C++Builder
Notice: Undefined variable: relatedArticlesCount in /home/wwwroot/codeback.net/plugins/content/tags.php on line 149

This example illustrate how to use the GetFormImage() and Assign() functions. Create a new project in the C++Building enviroment. Drag an image, a button, and a shape component onto the form. Adding the following codes to the event handler. Run the program and clicks the button. The image of the form would be stored in the pImage variable and copied to the Clipboard. Then image of the form in clipboard would be copied back to the image component and showed, produce an interesting result, especially if the button is clicked multiple times.

Note: remember to include the "clipbrd.hpp" in your header file.

#include "clipbrd.hpp"

void __fastcall TForm1::Button1Click(TObject *Sender)
{
  Graphics::TBitmap *pImage = GetFormImage();
  try
  {
    Clipboard()->Assign(pImage);
    Image1->Picture->Assign(Clipboard());
  }
  __finally
  {
    delete pImage;
  }
}


void __fastcall TForm1::FormCreate(TObject *Sender)
{
  Shape1->Shape = stEllipse;
  Shape1->Brush->Color = clBlue;
  Image1->Stretch = true;
}


Add comment


Security code
Refresh

Programming - C++Builder