Add canvas to GroupBox

Posted in Components

You should create a new type with Canvas property and use this new type for the type cast.

type TNewGroupBox = class(TGroupBox)
public
  property Canvas;
end;
...
procedure TForm1.Button1Click(Sender: TObject);
var
  MyBitmap: TBitmap;
begin
  MyBitmap:=TBitmap.Create;
  MyBitmap.LoadFromFile('factory.bmp');
  with TNewGroupBox(GroupBox1).Canvas do
    StretchDraw(
      Rect(0,0,MyBitmap.Width,MyBitmap.Height),
      MyBitmap);
end;