Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Default image in ppDBImage

edited July 2008 in General
I would like to place a default JPEG image in a ppDBImage that is empty.

Where is a good place to do this. Of course, I would like to show this
default image in the print preview and also on the print out
(if the ppDBImage does not find a image in the database)


var
JPG: TJPEGImage;

begin
if (ppDBImage3.Picture.Graphic.Empty) and (gAlbumShowPlaceHolders) then
begin
Jpg := GetResourceAsJpeg('place_holder_obverse');
ppDBImage3.Picture.Bitmap.Assign(Jpg);
Jpg.Free;
end;
end;


Thanks

Comments

  • edited July 2008

    You can use the DBImage.OnGetPicture event. Here is a downloadable example

    www.digital-metaphors.com/tips/UseDBImageOnGetPictureEvent.zip

    Here is the event-handler code...

    procedure TForm1.ppDBImage1GetPicture(Sender: TObject; aPicture: TPicture);
    var
    lPicture: TPicture;
    begin

    // call DataPipeline.GetFieldAsPicture method
    lPicture := plBioLife.GetFieldAsPicture('Graphic');

    if lPicture <> nil then
    aPicture.Assign(lPicture)
    else
    aPicture.Assign(FDefaultPicture);

    // for this example, replace the third image on each page
    if ppReport1.DetailBand.Count = 3 then
    aPicture.Assign(FDefaultPicture);

    end;




    --
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited July 2008
    ahhhh, i tried this in the past, using the Tpicture's "Empty" property, but
    i will try it now using the code below and see if it works

    thanks



This discussion has been closed.