Detecting in Run time if Template has image assigned in Design Time
D10.2, RB 19.04 Win10 Build 146
My client has a report that loads a template at Run time, depending on various criteria.
They also load the Logo for a TppImage at runtime to be used in the Template.
They have recently deviated from their own protocol and I need to make it possible for the program to
1. Detect if the loaded template has a design time logo already and, if so, to use it
else
2. Load the assigned logo
procedure TBillingExportDM.ppLogoImagePrint(Sender: TObject);
var
Filename: string;
begin
// Use the logos dir if it exists. Else default to using the RootDir.
if DirectoryExists(ExtractFilePath(Application.ExeName) + 'Logos') then
Filename := ExtractFilePath(Application.ExeName) + 'Logos\' +
InvoiceHeader.FieldByName('logo_filename').AsString
else
Filename := DestinationDir + 'Logos\' +
InvoiceHeader.FieldByName('logo_filename').AsString;
Assert(Assigned(ppLogoImage));
if FileExists(Filename) then
begin
if ppLogoImage.Picture = 'NONE' then this done not work but is the result I want.
ppLogoImage.Picture.LoadFromFile(Filename);
end
else
ppLogoImage.Clear;
end;
How can I achieve the desired result?
Thanks
My client has a report that loads a template at Run time, depending on various criteria.
They also load the Logo for a TppImage at runtime to be used in the Template.
They have recently deviated from their own protocol and I need to make it possible for the program to
1. Detect if the loaded template has a design time logo already and, if so, to use it
else
2. Load the assigned logo
procedure TBillingExportDM.ppLogoImagePrint(Sender: TObject);
var
Filename: string;
begin
// Use the logos dir if it exists. Else default to using the RootDir.
if DirectoryExists(ExtractFilePath(Application.ExeName) + 'Logos') then
Filename := ExtractFilePath(Application.ExeName) + 'Logos\' +
InvoiceHeader.FieldByName('logo_filename').AsString
else
Filename := DestinationDir + 'Logos\' +
InvoiceHeader.FieldByName('logo_filename').AsString;
Assert(Assigned(ppLogoImage));
if FileExists(Filename) then
begin
if ppLogoImage.Picture = 'NONE' then this done not work but is the result I want.
ppLogoImage.Picture.LoadFromFile(Filename);
end
else
ppLogoImage.Clear;
end;
How can I achieve the desired result?
Thanks
Comments
This is what I am going with.
RB leverages Delphi's TPicture/TGraphic architecture.
Here's an example:
Best regards,
Nard Moseley
Digital Metaphors
www.digital-metaphors.com