GetFormImage (C++)

From RAD Studio Code Examples
Jump to: navigation, search

Description

This example uses an image, a button, and a shape component on a form. When you click the button, an image of the form is stored in the FormImage variable and copied to the Clipboard. The image of the form is then copied back to the image component, producing an interesting result, especially if the button is clicked multiple times. Add ExtCtrls, StdCtrls, and Clipbrd to the uses clause. }


Code

#include <Clipbrd.hpp>

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

__fastcall TForm1::TForm1(TComponent* Owner)
  : TForm(Owner)
{
  Shape1->Shape = stEllipse;
  Shape1->Brush->Color = clLime;
  Image1->Stretch = true;
}

Uses

Personal tools
Assistance