Programming C++Builder An example on how to use GetFormImage() and Assign() functions in C++Builder

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();
    delete pImage;

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

Add comment

Security code

Programming - C++Builder