Updating the contents of frxPictureView
BJL
Brussels, Belgium
Working with BCB6 and FR3.04
In an application, the user makes some selections which result in a metafile. The design of the report includes a TfrxPictureView to display the metafile. This works well.
After closing the preview, the user may change part of its initial selections to generate a new report (using the same FR3 file and the same frxReport). Though the program has produced a revised metafile (under the same name), when the report appears, it still shows the old metafile, despite the fact that the frxReport is Cleared and the FR3 loaded again. The FR3 does not include the metafile assignment, which is done in the BCB code.
I have tried, in the BCB code, to remove the picture from the frxPictureView before reloading the updated metafile without success.
Here is my code
Any idea to solve this problem?
Happy new year! Bonne ann?©e! Gl??ckliches neues Jahr!
In an application, the user makes some selections which result in a metafile. The design of the report includes a TfrxPictureView to display the metafile. This works well.
After closing the preview, the user may change part of its initial selections to generate a new report (using the same FR3 file and the same frxReport). Though the program has produced a revised metafile (under the same name), when the report appears, it still shows the old metafile, despite the fact that the frxReport is Cleared and the FR3 loaded again. The FR3 does not include the metafile assignment, which is done in the BCB code.
I have tried, in the BCB code, to remove the picture from the frxPictureView before reloading the updated metafile without success.
Here is my code
 Chart->Visible = true;
 String WmfFile = ExtractFilePath(Application->ExeName) + "Chart.wmf";
 // these 2 following lines have no effect...
 HENHMETAFILE hMetaFile = GetEnhMetaFile(WmfFile.c_str());
 DeleteEnhMetaFile(hMetaFile);
 Chart->SaveToMetafileEnh(WmfFile);
 Chart->Visible = false;
 String DesignFile = ExtractFilePath(Application->ExeName) + "TempChart.fr3";
 frxReport1->Clear();
 frxReport1->LoadFromFile(DesignFile);
 TfrxPictureView* v = (TfrxPictureView*)frxReport1->FindObject("Picture1");
 v->Picture->LoadFromFile(WmfFile);
 frxReport1->PrepareReport(false);
 frxReport1->ShowPreparedReport();
Any idea to solve this problem?
Happy new year! Bonne ann?©e! Gl??ckliches neues Jahr!
Comments
Cheers
/Johan
Cheers
Johan
new method for fr3
use a pictureview object instead. and the obp event of report component.
procedure TForm1.frxReport1BeforePrint(Sender: TfrxReportComponent);
begin
if Sender.Name='Picture1'then
TfrxPictureView(Sender).Picture.Assign(form2.Chart1.TeeCreateMetafile(False,
Rect(0, 0, Round(Sender.Width), Round(Sender.Height))));
end;
Using TeeCreateMetaFile is handy when it is not necessary to keep the metafile on disk.
In my case, I could not solve the problem by moving the code to the Report obp.
I have tried to add the frxPictureView at run time, hoping to remove it after closing the preview. But I could not find a way to remove the picture view object.
My present code is the following with the same problem as explained in the first message. However, when using the editor of the PictureView object, there is a CLEAR button which removes the pisture at design time. Which function is this button using?
frxReport1->ShowPreparedReport();
delete v;// this line is not accepted and leads to an error.
of course as you are beyond the design stream after calling
preparereport.
the code i gave you assumes an empty pictureview object.
and by using the external obp event will always load whatever is current when encountered in the report.
for initial clearing for example of a pictureview object in the report
try something like
pv:tfrxpictureview;
frxreport1.loadfromfile('blah');
pv := frxreport1.finobject('Picture1');
pv.picture.clear;
or pv.picture := nil;
pv.clear;