FillRect don't work properly? lazarus / 39-Graphics ---------------------------------------------------------------------- oraculus · 2015-02-07 10:46 Hello. When I assign the height of a TImage and fill it with a color, all work well. But when I make the height of the TImage more big, the TImage only fill with the first values. Here are the code example: Code: [Select]  TvAsp: TImage;   (...)   Form1.TvAsp.Height:= 100;   Form1.TvAsp.Canvas.Clear;   Form1.TvAsp.Canvas.Brush.Color:=RGBToColor(255,255,255);   Form1.TvAsp.Canvas.FillRect(Form1.TvAsp.BoundsRect);   (...)   Form1.TvAsp.Height:= 300;   Form1.TvAsp.Canvas.Clear;   Form1.TvAsp.Canvas.Brush.Color:=RGBToColor(255,255,255);   Form1.TvAsp.Canvas.FillRect(Form1.TvAsp.BoundsRect);// Only fill a Height of 100 It is a Lazarus's mistake? Thank-you. ---------------------------------------------------------------------- taazz · 2015-02-07 12:19 Quote from: oraculus on February 07, 2015, 11:46:08 amHello. When I assign the height of a TImage and fill it with a color, all work well. But when I make the height of the TImage more big, the TImage only fill with the first values. Here are the code example: Code: [Select]  TvAsp: TImage;   (...)   Form1.TvAsp.Height:= 100;   Form1.TvAsp.Canvas.Clear;   Form1.TvAsp.Canvas.Brush.Color:=RGBToColor(255,255,255);   Form1.TvAsp.Canvas.FillRect(Form1.TvAsp.BoundsRect);   (...)   Form1.TvAsp.Height:= 300;   Form1.TvAsp.Canvas.Clear;   Form1.TvAsp.Canvas.Brush.Color:=RGBToColor(255,255,255);   Form1.TvAsp.Canvas.FillRect(Form1.TvAsp.BoundsRect);// Only fill a Height of 100 It is a Lazarus's mistake? Thank-you. Form1.TvAsp.BoundsRect has different values between those two calls? EDIT: Ok here is a small explanation of TImage. TImage is a control that shows on screen the contents of what ever is loaded in its picture property. It has the ability to resize it to fit in the area enclosed by timage it self. It has no content you can draw on and it is a simple gateway to the underline graphic data that picture points to. If nothing is loaded in the picture property then the timage has no contents and nowhere to draw to. To overcome this problem the team decided to auto create a bitmap the first time you try to draw something and you have not loaded or created any picture to draw to, they used the TImage's size as the bitmaps size after that first creation the bitmap persist through out the life of timage it self until you change it your self. ---------------------------------------------------------------------- howardpc · 2015-02-07 12:52 You may find it more to your purpose to use ClientRect rather than BoundsRect for scrollable controls such as forms. ---------------------------------------------------------------------- zeljko · 2015-02-07 13:59 He is using BoundsRect of TImage, not TForm one. ---------------------------------------------------------------------- howardpc · 2015-02-07 15:00 Ah, zeljko, you're right. My mistake. ---------------------------------------------------------------------- oraculus · 2015-02-07 18:08 Thank-you. In my program, I put the TImage inside a ScrollBox. I need that TImage's size changes into relation with the number of canvas that the program uses in every case. How can I do it? ---------------------------------------------------------------------- howardpc · 2015-02-07 19:30 Can you provide your current compilable code (with its resizing shortcomings)? Then I expect someone can point you towards changes that would make it behave how you want it to. Code snippets are unsatisfactory, because others have to make too many assumptions about the parts (could be 99% of your program) that are not known except to you. ---------------------------------------------------------------------- oraculus · 2015-02-07 20:13 Yes. here it is: http://astroser.net/syrius_fuente.zip When you select the "Tecnicas" tab, put for example "36" in "Dias" text box, and press "Transitos" button. You can see planetary transits for 36 days. Now put "365" in "Dias" text box, and press "Transitos" button. You can't see planetary transits for 365 days. The list of planetary transits must be much bigger, but the "TvAsp" TImage control don't resize. It will be interesting to publish the solution in this forum. ---------------------------------------------------------------------- howardpc · 2015-02-07 22:45 Try changing the beginning of your procedure to the following: Code: [Select]procedure listaTecnicas(op: integer); var   f: TextFile;   np, tx, tx2, nb1, nb2: string;   nbp: array of string;   contador, ini, fin, fig, tam, distancia: integer;   sc: single;   py: longint; begin   Form1.listaTec.Items.Clear;   if op = 1 then   begin     AssignFile(F, ExtractFilePath(Application.ExeName) + 'transitos.txt');   end   else if op = 2 then   begin     AssignFile(F, ExtractFilePath(Application.ExeName) + 'sinastria.txt');   end;   Reset(f);   // Aspectos en plan grafico   contador := 0;   while not EOF(f) do   begin     Application.ProcessMessages;     ReadLn(f, tx);     nbp := vbSplit(tx, ' ');     if ((Length(nbp[0]) > 1)) then     begin       contador := contador + 1;     end;   end; // changes start here:   Form1.TvAsp.Picture.Bitmap.SetSize(Form1.Width, contador * 20);   Form1.TvAsp.Picture.Bitmap.Canvas.Brush.Color:=RGBToColor(255,255,25 5); // Para que funcione   Form1.TvAsp.Picture.Bitmap.Canvas.FillRect(Form1.TvAsp.BoundsRect);   SetBkMode(Form1.TvAsp.Picture.Bitmap.Canvas.Handle, TRANSPARENT);   Form1.TvAsp.Picture.Bitmap.Canvas.Brush.Color:=RGBToColor(255,255,25 5); // en Win y en Linux   Form1.TvAsp.Picture.Bitmap.Canvas.Pen.Width:=1;   Form1.TvAsp.Picture.Bitmap.Canvas.Font.Size:=8;   contador := 0;   Reset(f);   while not EOF(f) do   begin     Application.ProcessMessages;     ReadLn(f, tx);     nbp := vbSplit(tx, ' ');     if ((Length(nbp[0]) > 1)) then     begin       contador := contador + 1;       py:=((contador -1) * 20) +1;       if (op = 1) then begin // Transitos         Form1.TvAsp.Picture.Bitmap.Canvas.Textout(1, py+3, nbp[0]);         fig:=simbolo(nbp[1]);         Dibuja_Planeta(False,Form1.TvAsp,Form1.sb,69,py,fig, 13);         tam:=12;         sc:=1;         distancia:=vbVal(nbp[2]);         Form1.TvAsp.Picture.Bitmap.Canvas.Pen.Color:=RGBToColor(0,0,0);         Form1.TvAsp.Picture.Bitmap.Canvas.Pen.Width:=1;         simboloAspecto(Form1.TvAsp,85,py+5,tam,distancia, sc);         fig:=simbolo(nbp[3]);         Dibuja_Planeta(False,Form1.TvAsp,Form1.sb,97,py,fig, 13);         Form1.TvAsp.Picture.Bitmap.Canvas.Textout(113, py+3, nbp[4]);         if (nbp[7] <> '(.)') then begin           ini:=vbInstr(nbp[7],'(');           fin:=vbInstr(nbp[7],')');           np:=Copy(nbp[7], ini+1, (fin-ini)-1); // Mid           distancia:=vbVal(np);           Form1.TvAsp.Picture.Bitmap.Canvas.Pen.Color:=RGBToColor(0,0,0);           Form1.TvAsp.Picture.Bitmap.Canvas.Pen.Width:=1;           simboloAspecto(Form1.TvAsp,198,py+5,tam,distancia, sc);         end;       end       else begin // Sinastria           ... etc. ---------------------------------------------------------------------- oraculus · 2015-02-08 10:17 Thank-you very much howardpc. My only change has been: Code: [Select]  Form1.TvAsp.Picture.Bitmap.SetSize(Form1.TvAsp.Width, contador * 20);   Form1.TvAsp.Height:= contador * 20; //  This must be still here And now all work properly.  You are more rapid than freepascal Best regards from Spain.