No report pages output
Hi, i am trying to set a variable from within my delphi app to try and load a dynamic picture, however when i do set this variable, there are no pages output in the report preview.
For example,
My code:
procedure ClientPic1OnBeforePrint(Sender: TfrxComponent);
begin
ShowMessage(<ClientLogo>);
TfrxPictureView(Sender).FileLink := <ClientLogo>;
end;
begin
Set('ClientLogo',#39+'c:\image.jpg'+#39);
end.
Works when i run the report from the designer, however when i try and set the report using:
RawViewReport.Variables.Variables := #39+FClientLogo+#39;
RawViewReport.ShowReport;
There are no pages output, and the ShowMessage(<CLientLogo>) doesnt even popup.
Whats going on?
I ahve also tried this to set a picture this way:
l2 := RawViewReport.FindObject('ClientPic1') as TFrxPictureView;
if FileExists(FClientLogo) then L2.Picture.LoadFromFile(#39+'C:\image.jpg'+#39);
Which doesnt work because l2 returns 'nil' when there is definately an object called 'ClientPic1'.
Please help, as this is behaving strange.
Simon
For example,
My code:
procedure ClientPic1OnBeforePrint(Sender: TfrxComponent);
begin
ShowMessage(<ClientLogo>);
TfrxPictureView(Sender).FileLink := <ClientLogo>;
end;
begin
Set('ClientLogo',#39+'c:\image.jpg'+#39);
end.
Works when i run the report from the designer, however when i try and set the report using:
RawViewReport.Variables.Variables := #39+FClientLogo+#39;
RawViewReport.ShowReport;
There are no pages output, and the ShowMessage(<CLientLogo>) doesnt even popup.
Whats going on?
I ahve also tried this to set a picture this way:
l2 := RawViewReport.FindObject('ClientPic1') as TFrxPictureView;
if FileExists(FClientLogo) then L2.Picture.LoadFromFile(#39+'C:\image.jpg'+#39);
Which doesnt work because l2 returns 'nil' when there is definately an object called 'ClientPic1'.
Please help, as this is behaving strange.
Simon
Comments
you are trying to access the variable incorrectly
RawViewReport.Variables.Variables := #39+FClientLogo+#39;
it should be
RawViewReport.Variables :=
also remember that when passing a string value from delphi into a categorized variable, extra delimiters are required.
Thanks Gordk, i have changed the .Variables.Variables to just one .Variables however both seemed to work ok. I am unfortunately still getting 0 pages when i try and dynamically set a picture in the report. I have on my delphi form an Timage to load a logo for the report. Then i have my code:
procedure TfrmReport.RawViewReportBeforePrint(Sender: TfrxReportComponent);
var L1 : TFrxPictureView;
s : String;
begin
s := Sender.Name;
if (LeftStr(s,Length(s)-1)) = 'ClientPic' then
begin
TfrxPictureView(Sender).FileLink := FclientLogo;
end;
end;
I have multiple TFrxPictureViews all named ClientPic1, ClientPic2, ClientPic3 etc... When i preview the report without loading the TImage component in my delphi form, the report is output with approx 70 pages. AS soon as i load the TImage component, then press preview, the report has 0 pages.
TfrxPictureView(Sender).FileLink := FclientLogo;
What is fclientlogo, a property you are trying to read?
if the logo is already in a delphi image component
just assign the image to the pictureviews picture.property.
Thankyou for the suggestion, however the report is still not printing any pages. On further invsetigation, i am able to set the variable from an edit box (i.e. typing 'c:\image.jpg' then running the report works setting the variable to Report.Variables := Edit1.text) but if i allow the user to select the image from a TOpenDialog which in turn sets the Property 'ClientLogo', the report fails. It is ONLY when i have an opendialog to choose the logo. VERY strange, any suggestions?
so you will have to find it yourself.
Ok, i will look in my application code, even though there is only 4 procedures on the form and they all seem to be right.
So my next question is: if i now try and set the pictureview a different way, using:
var L1 : TFrxPictureView;
begin
RawViewReport.Report.LoadFromFile('SiteReport.fr3');
L1 := RawViewReport.FindObject('ClientPic1') as tFrxPictureView;
if not assigned(L1) then ShowMessage('Cannot find pictureview');
if FileExists(Mainform.ClientLogo) then L1.Picture.LoadFromFile(MainForm.ClientLogo);
RawViewReport.ShowReport;
end;
the picture never gets set because L1 always returns nil and the message 'Cannot find pictureview' displays. Why is this occuring when i have a TFrxPictureView in my report called 'ClientPic1'?
EDIT:
There seems to be a problem in the frxXMLSerializer.pas unit -> looks like a memory allocation problem.
Call Stack Information:
|Address |Module |Unit |Class |Procedure/Method |Line |
|Running Thread: ID=3132; Priority=0; Class=; [Main] |
|
|
|7C90CF5A|ntdll.dll | | |NtAllocateVirtualMemory| |
|7C809B2C|kernel32.dll | | |VirtualAllocEx | |
|0078BAA7|SurePlay2.exe|frxXMLSerializer.pas| |DoNonPublishedProps |531[7] |
|0078BA30|SurePlay2.exe|frxXMLSerializer.pas| |DoNonPublishedProps |524[0] |
|0078BF28|SurePlay2.exe|frxXMLSerializer.pas|TfrxXMLSerializer |ObjToXML |629[64] |
|0078BC68|SurePlay2.exe|frxXMLSerializer.pas|TfrxXMLSerializer |ObjToXML |565[0] |
|0078B9AB|SurePlay2.exe|frxXMLSerializer.pas| |DoClassProp |515[56] |
|0078B6DC|SurePlay2.exe|frxXMLSerializer.pas| |DoClassProp |459[0] |
|0078BDE4|SurePlay2.exe|frxXMLSerializer.pas|TfrxXMLSerializer |ObjToXML |601[36] |
|0078BC68|SurePlay2.exe|frxXMLSerializer.pas|TfrxXMLSerializer |ObjToXML |565[0] |
|0078C40A|SurePlay2.exe|frxXMLSerializer.pas| |DoWrite |752[8] |
|0078C350|SurePlay2.exe|frxXMLSerializer.pas| |DoWrite |744[0] |
|0078C456|SurePlay2.exe|frxXMLSerializer.pas| |DoWrite |755[11] |
|0078C350|SurePlay2.exe|frxXMLSerializer.pas| |DoWrite |744[0] |
|0078C456|SurePlay2.exe|frxXMLSerializer.pas| |DoWrite |755[11] |
|0078C350|SurePlay2.exe|frxXMLSerializer.pas| |DoWrite |744[0] |
|0078C51B|SurePlay2.exe|frxXMLSerializer.pas|TfrxXMLSerializer |WriteRootComponent |771[13] |
|0078C4C0|SurePlay2.exe|frxXMLSerializer.pas|TfrxXMLSerializer |WriteRootComponent |758[0] |
|007971E5|SurePlay2.exe|frxClass.pas |TfrxComponent |SaveToStream |4393[8] |
|00797174|SurePlay2.exe|frxClass.pas |TfrxComponent |SaveToStream |4385[0] |
|007A4742|SurePlay2.exe|frxClass.pas |TfrxReport |SaveToStream |12381[31]|
|007A6360|SurePlay2.exe|frxClass.pas |TfrxReport |PrepareReport |12920[23]|
|007A6280|SurePlay2.exe|frxClass.pas |TfrxReport |PrepareReport |12897[0] |
|007A6738|SurePlay2.exe|frxClass.pas |TfrxReport |OnTimer |13062[2] |
|7E4196C2|user32.dll | | |DispatchMessageA | |
|7E4196B8|user32.dll | | |DispatchMessageA | |
|007A667B|SurePlay2.exe|frxClass.pas |TfrxReport |ShowPreparedReport |13006[23]|
|007A65C4|SurePlay2.exe|frxClass.pas |TfrxReport |ShowPreparedReport |12983[0] |
|007A6718|SurePlay2.exe|frxClass.pas |TfrxReport |ShowReport |13052[19]|
|007A66D4|SurePlay2.exe|frxClass.pas |TfrxReport |ShowReport |13033[0] |
|00984B97|SurePlay2.exe|ReportUnit.pas |TfrmReport |AdvGlowButton3Click |202[27] |
|0055B74F|SurePlay2.exe|AdvGlowButton.pas |TAdvCustomGlowButton|Click |2594[5] |
|0055C0F9|SurePlay2.exe|AdvGlowButton.pas |TAdvCustomGlowButton|WMLButtonUp |3016[105]|
|7C9010E0|ntdll.dll | | |RtlLeaveCriticalSection| |
|7E4194DA|user32.dll | | |GetCapture | |
|7E42B3FC|user32.dll | | |CallNextHookEx | |
|7E4196C2|user32.dll | | |DispatchMessageA | |
|7E4196B8|user32.dll | | |DispatchMessageA | |
|0099A9FB|SurePlay2.exe|SurePlay2.dpr | | |58[30] |
|7C90DC9A|ntdll.dll | | |NtSetInformationThread | |
public
pic : String;
procedure TForm1.Button1Click(Sender: TObject);
begin
if OpenDialog1.Execute then
begin
Image1.Picture.LoadFromFile(OpenDialog1.Filename);
Pic := OpenDialog1.FileName;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
frxReport1.Report.LoadFromFile('Dummy.fr3');
frxReport1.Variables := #39+pic+#39;
frxReport1.ShowReport(true);
end;
Which fails everytime i try to load an image. Dummy.fr3 consists of a single TfrxPictureView with the Onbeforeprint method as follows:
Picture1.Picture.LoadFromFile(Get('Logo'));
I dont think this is a problem with my code, unless you can see something gordk.
Unfortunately this also does not work. From what i have read in the manual, Get('Logo') and <logo> are interchangeable.
Is there a particular reason there are no output report pages? Why doesnt the component (frxPictureView or anything else for that matter) just go invisible when it cant evaluate it contents, instead of making the whole report invisible?
var pic:string;
begin
if opendialog3.execute then
begin
pic:=opendialog3.filename;
frxreport4.LoadFromFile(wpath+'pictest.fr3');
frxreport4.variables:= #39+pic+#39;
frxreport4.showreport;
end;
end;
the above code works fine for me.
wpath is a public string variable to app path