I narrowed down the problem I draw on TImage.Canvas in Delphi 2009 to the following reproducible case:
Indicated: form, a TImage , TLabel and TButton on it. TImage tied to all four edges, so resizing the form will resize the TImage . What I want to do is use the maximum Image1 area available to me after resizing. Therefore, in my test case, I have the following code in my Button OnClick handler:
procedure TForm1.Button1Click(Sender: TObject); begin Label1.Caption:= IntToStr (Image1.Width)+' x '+IntToStr(Image1.Height); Image1.Canvas.Pen.Color:= 0; Image1.Canvas.Rectangle(0,0,Image1.Width, Image1.Height); end;
You'll see that if the form is resized,
Image1.Width and
.Height change as expected, however the rectangle that is drawn if the resized form is larger than the original one, will be incomplete, only drawing on the same area that was there previously.
How do I do this, use the entire modified area?
For what it's worth, in my original problem I was playing with Image1.Stretch , which allows me to use more area when resizing, but will lead to distortion of my drawings (not desirable). If I also use Image1.Proportional , then this is better, but I still cannot use the entire available area. Image1.AutoSize doesn't seem to be doing anything useful to me.
Any help was appreciated.
source share