简体   繁体   English

TImage宽度/高度锚点不起作用

[英]TImage width / height anchor not working

I've got a TForm which has an Event FormResize , within that function I want to draw something within my TImage. 我有一个TForm具有Event FormResize ,在该函数中我想在TImage中绘制一些东西。

My FormResize function looks like below 我的FormResize函数如下所示

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. 白色背景/画布来自TImage。 The TImage is Anchored in all 4 directions. TImage在所有4个方向上均被锚定。

Anyone knows how to also make the image able to resize bigger? 有谁知道如何也可以使图像的尺寸变大?

屏幕截图原图较小较大

Use a TPaintBox instead of a TImage and do your drawing in the TPaintBox::OnPaint event. 使用TPaintBox而不是TImage ,并在TPaintBox::OnPaint事件中进行绘制。 Then you don't need to use the TForm::OnResize event anymore. 然后,您不再需要使用TForm::OnResize事件。

void __fastcall TForm1::ViewPortPaintBoxPaint(TObject *Sender)
{
    // Teken de blokjes
    _viewPort->draw(ViewPortPaintBox->Canvas, ViewPortPaintBox->ClientWidth, ViewPortPaintBox->ClientHeight);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM