Changing Picture at runtime
Hi,
we are using RB 10.06.
I created an image (logoKopf) in the detailband of the report. In RAP in the
onDrawCommandClick-Event i coded
var
lbOK: boolean;
begin
lbOK:= ExecuteImageSelect(logoKopf);
In my project, i coded the ExecuteImageSelect-Function:
TmyImageSelectFunction = class (TraSystemFunction)
public
class function Category: string; override;
procedure ExecuteFunction(aParams: TraParamList); override;
class function GetSignature: string; override;
procedure TmyImageSelectFunction.ExecuteFunction(aParams: TraParamList);
var
lbOK: boolean;
lppImage: TppImage;
lPictureDlg: TOpenPictureDialog;
lReport: TppReport;
begin
GetParamValue(0, lppImage);
lbOk:= true;
if not (lppImage = nil) then begin
lReport:= tppReport(lppImage.Report.MainReport);
if not (lReport = nil) then begin
lPictureDlg := TOpenPictureDialog.Create(Application);
if lPictureDlg.Execute then begin
lppImage.Picture.LoadFromFile(lPictureDlg.FileName);
end;
FreeAndNil(lPictureDlg);
lReport.PrintToDevices;
end;
end;
SetParamValue(1, lbOK);
end;
After executing this function and selecting a new image, it is not longer
possible to save template (e.g. lReport.Template.SaveToStream). I just can
stop the Debugger by STRG+F2.
Other individual functions, for example to change the font for a component,
work fine and I don't have any problems to save the report after calling the
function.
procedure TmyChangeFontFunction.ExecuteFunction(aParams: TraParamList);
var
lbOK: boolean;
lComponent: tppComponent;
lReport: tppReport;
lFontDialog: TFontDialog;
begin
GetParamValue(0, lComponent);
lbOk:= true;
if not (lComponent = nil) then begin
if (lComponent is tppLabel) or
(lComponent is tppDBText) then begin
lReport:= tppReport(lComponent.Report.MainReport);
if not (lReport = nil) then begin
lFontDialog:= TFontDialog.Create(Application);
if (lComponent is tppLabel) then
lFontDialog.Font.Assign(tppLabel(lComponent).Font);
if (lComponent is tppDBText) then
lFontDialog.Font.Assign(tppDBText(lComponent).Font);
if lFontDialog.Execute then begin
if (lComponent is tppLabel) then
tppLabel(lComponent).Font.Assign(lFontDialog.Font);
if (lComponent is tppDBText) then
tppDBText(lComponent).Font.Assign(lFontDialog.Font);
end;
lFontDialog.Free;
lReport.PrintToDevices;
end;
end;
end;
SetParamValue(1, lbOK);
end;
Any idea ?
Marion
we are using RB 10.06.
I created an image (logoKopf) in the detailband of the report. In RAP in the
onDrawCommandClick-Event i coded
var
lbOK: boolean;
begin
lbOK:= ExecuteImageSelect(logoKopf);
In my project, i coded the ExecuteImageSelect-Function:
TmyImageSelectFunction = class (TraSystemFunction)
public
class function Category: string; override;
procedure ExecuteFunction(aParams: TraParamList); override;
class function GetSignature: string; override;
procedure TmyImageSelectFunction.ExecuteFunction(aParams: TraParamList);
var
lbOK: boolean;
lppImage: TppImage;
lPictureDlg: TOpenPictureDialog;
lReport: TppReport;
begin
GetParamValue(0, lppImage);
lbOk:= true;
if not (lppImage = nil) then begin
lReport:= tppReport(lppImage.Report.MainReport);
if not (lReport = nil) then begin
lPictureDlg := TOpenPictureDialog.Create(Application);
if lPictureDlg.Execute then begin
lppImage.Picture.LoadFromFile(lPictureDlg.FileName);
end;
FreeAndNil(lPictureDlg);
lReport.PrintToDevices;
end;
end;
SetParamValue(1, lbOK);
end;
After executing this function and selecting a new image, it is not longer
possible to save template (e.g. lReport.Template.SaveToStream). I just can
stop the Debugger by STRG+F2.
Other individual functions, for example to change the font for a component,
work fine and I don't have any problems to save the report after calling the
function.
procedure TmyChangeFontFunction.ExecuteFunction(aParams: TraParamList);
var
lbOK: boolean;
lComponent: tppComponent;
lReport: tppReport;
lFontDialog: TFontDialog;
begin
GetParamValue(0, lComponent);
lbOk:= true;
if not (lComponent = nil) then begin
if (lComponent is tppLabel) or
(lComponent is tppDBText) then begin
lReport:= tppReport(lComponent.Report.MainReport);
if not (lReport = nil) then begin
lFontDialog:= TFontDialog.Create(Application);
if (lComponent is tppLabel) then
lFontDialog.Font.Assign(tppLabel(lComponent).Font);
if (lComponent is tppDBText) then
lFontDialog.Font.Assign(tppDBText(lComponent).Font);
if lFontDialog.Execute then begin
if (lComponent is tppLabel) then
tppLabel(lComponent).Font.Assign(lFontDialog.Font);
if (lComponent is tppDBText) then
tppDBText(lComponent).Font.Assign(lFontDialog.Font);
end;
lFontDialog.Free;
lReport.PrintToDevices;
end;
end;
end;
SetParamValue(1, lbOK);
end;
Any idea ?
Marion
This discussion has been closed.
Comments
When exactly are you trying to save the template? When you execute the
pass-thru function, does the image properly change once you print?
I'm a bit unclear about what happens when you try to save. Do you receive
an error? Are you able to trace into the RB source when the error occurs?
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
that I can run on my machine in .zip format to support@digital-metaphors.com
and I'll take a look at it for you.
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com