0

I've got a TForm which has an Event FormResize, within that function I want to draw something within my TImage.

My FormResize function looks like below

void __fastcall TForm1::FormResize(TObject *Sender)
{
    // Teken de blokjes
    _viewPort->draw(_viewPortImage->Canvas, _viewPortImage->Width, _viewPortImage->Height);
}

Within this function I do nothing more than drawing a rectangle which draws a border:

ViewPort::draw(Vcl::Graphics::TCanvas* Canvas, int width, int height)
{
    Canvas->Rectangle(0, 0, width, height);
}

Now the problem. When I make the form smaller than the original it scales well. but when the form gets bigger than the original size. The background + Border is not drawn well. See the screenshot below. The white background / Canvas is from the TImage. The TImage is Anchored in all 4 directions.

Anyone knows how to also make the image able to resize bigger?

Screenshot original smaller bigger

Johan
  • 74,508
  • 24
  • 191
  • 319
Niels
  • 48,601
  • 4
  • 62
  • 81

1 Answers1

0

Use a TPaintBox instead of a TImage and do your drawing in the TPaintBox::OnPaint event. Then you don't need to use the TForm::OnResize event anymore.

void __fastcall TForm1::ViewPortPaintBoxPaint(TObject *Sender)
{
    // Teken de blokjes
    _viewPort->draw(ViewPortPaintBox->Canvas, ViewPortPaintBox->ClientWidth, ViewPortPaintBox->ClientHeight);
}
Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770