Dynamically adding TppImage objects
Hello,
I am trying to add TppImage objects dynamically on a detail band. At least
one detail record exits to print the detail band. But the code does not
print image at all. All the image files surely exist and if I create a
TppImage object design time, the images are shown without any problem. In
the code below, image1 obejct is created in the design time and shows the
image.
I am trying to create as many pages as the number of images that I add into
the FileList variable.
Is this possible???
Thanks,
Shoji
procedure DetailBeforeGenerate;
var
FileList : TStringList;
I : Integer;
ImageTop : Integer;
ppImage : TppImage;
begin
FileList := TStringList.Create;
FileList.Clear;
FileList.Add('c:\vcs\hsvrs\vrs reports\Adopt.jpg');
FileList.Add('c:\vcs\hsvrs\vrs reports\Delayed.jpg');
FileList.Add('c:\vcs\hsvrs\vrs reports\Foreign.jpg');
FileList.Add('c:\vcs\hsvrs\vrs reports\Rotated.jpg');
if FileList.Count > 0 then
begin
Image1.Picture.LoadFromFile(FileList[0]);
ImageTop := 0;
for I := 0 to FileList.Count - 1 do
begin
ppImage := TppImage.Create(Image1.Owner);
ppImage.Parent := Image1.Parent;
ppImage.Left := 0;
ppImage.Top := ImageTop;
ppImage.Width := 7.46;
ppImage.Stretch := True;
ppImage.Visible := True;
ppImage.Picture.LoadFromFile(FileList[I]);
ImageTop := ImageTop + 1.6;
end;
end;
FileList.Free;
end;
This discussion has been closed.
Comments
- when creating components, use the report.Owner
- rather than setting ppImage.Parent, you need to set the ppImage.Band
property to ppReport.DetailBand (to add the component to detailband).
- no need to set Image.Visible to true, that is the default value
Example:
myImage := TppImage.Create(myReport.Owner);
myImage.Band := myReport.DetailBand;
--
Nard Moseley
Digital Metaphors
www.digital-metaphors.com
Best regards,
Nard Moseley
Digital Metaphors
www.digital-metaphors.com
I tried it and the image objects still (if ever created) do not show images,
nor the detail band does not expand to create a second page.
Do you have any idea??? Does the detail band ever creates subsequent
pages???
Thanks,
Shoji
procedure DetailBeforeGenerate;
var
FileList : TStringList;
I : Integer;
ImageTop : Integer;
ppImage : TppImage;
begin
FileList := TStringList.Create;
FileList.Clear;
FileList.Add('c:\vcs\hsvrs\vrs reports\Adopt.jpg');
FileList.Add('c:\vcs\hsvrs\vrs reports\Delayed.jpg');
FileList.Add('c:\vcs\hsvrs\vrs reports\Foreign.jpg');
FileList.Add('c:\vcs\hsvrs\vrs reports\Rotated.jpg');
if FileList.Count > 0 then
begin
Image1.Picture.LoadFromFile(FileList[0]);
ImageTop := Image1.Top + Image1.Height;
for I := 0 to FileList.Count - 1 do
begin
ppImage := TppImage.Create(Image1.Owner);
ppImage.Band := Detail;
ppImage.Left := 0;
ppImage.Top := ImageTop;
ppImage.Height := 5.5;
ppImage.Width := 7.46;
ppImage.Stretch := True;
ppImage.Picture.LoadFromFile(FileList[I]);
ImageTop := ImageTop + 5.7;
end;
end;
FileList.Free;
end;
- Do not use DetailBand.BeforeGenerate
- Try using the Report.IniitalizeParameters event or perhaps
Report.BeforePrint. Event BeforePrint can fire multiple times - once when
you preview and again when you print, etc. Add some code to either free the
TppImage objects and recreate them or check whether they already exist and
do not create more.
- Add code to set the DetailBand.Height to accomodate the images.
- Set DetailBand.PrintHeight to phDynamic to enable the band to overflow to
additional pages.
--
Nard Moseley
Digital Metaphors
www.digital-metaphors.com
Best regards,
Nard Moseley
Digital Metaphors
www.digital-metaphors.com
That works!
Thanks, Nard.
Shoji Kaburagi
Software Developer
Netsmart Technologies, Inc.
skaburagi@ntst.com