Conversion EMFPages from FR2 to FR3?
Hello,
I would like to convert my code (that works for FR2) also for FR3. The code works with finished reports (*.frp), it changes the number of version (Memo value), saves it and print.
Maybe I need to use frxReport1.PreviewPages....(FR3) instead of frReport.EMFPages....(FR2), but I'm not sure and I have no idea. Please, could you help me ?
Ludek Los
Here is the code that works for me in D7 for FR2:
I would like to convert my code (that works for FR2) also for FR3. The code works with finished reports (*.frp), it changes the number of version (Memo value), saves it and print.
Maybe I need to use frxReport1.PreviewPages....(FR3) instead of frReport.EMFPages....(FR2), but I'm not sure and I have no idea. Please, could you help me ?
Ludek Los
Here is the code that works for me in D7 for FR2:
procedure TReportForm.ArchivCall(NameOfFile:string;Action:integer;Edition:integer);
 procedure ActionProc;
 var ExpPath:string;
  procedure ChangeValue(Name_1,Name_2,Value : shortstring);
  var
   i: Integer;
   PomPageInfo: PfrPageInfo;
   PomObj:TfrView;
   PomPageCount:integer;
   procedure IncEdition;
   var LokStr:string;
     LokCisVyd:integer;
   begin
    LokStr:=PomObj.Memo[0];
    LokCisVyd:=0;
    try
     LokCisVyd:=StrToInt(LokStr);
    except on e:EConvertError do begin
     {is not a number}
    end
    end;
    inc(LokCisVyd);
    Value:=IntToStr(LokCisVyd);
    PomObj.Memo.Clear; PomObj.Memo.Add(Value);
   end;
  begin
   if not(MessageDlg(Increase a number of editon',
   mtConfirmation{mtWarning}, [mbYes, mbNo], 0) = mrYes) then exit;
   PomPageCount:=frReport1.EMFPages.Count;
   for i := 0 to PomPageCount - 1 do begin
    PomPageInfo := frReport1.EMFPages.List[i];
    with PomPageInfo^ do
    begin
     if {Visible}true then begin
      if Page = nil then
       frReport1.EMFPages.ObjectsToPage(i);
      PomObj := TFrView(Page.FindObject(Name_1));
      if PomObj <> nil then
      begin
       if Edition<0 then begin
        IncEdition;
       end
       else begin
        PomObj.Memo.Clear; PomObj.Memo.Add(Value);
       end;
      end;
      PomObj := TFrView(Page.FindObject(Name_2));
      if PomObj <> nil then
      begin
       if Edition<0 then begin
        IncEdition;
       end
       else begin
        PomObj.Memo.Clear; PomObj.Memo.Add(Value);
       end;
      end;
      frReport1.EMFPages.PageToObjects(i);
      Page.Free;
      Page := nil;
     end;
    end;
   end;
   if Edition<0 then begin
    frReport1.SavePreparedReport(NameOfFile);
    frReport1.LoadPreparedReport(NameOfFile);
   end;
  end;
 begin
  NameOfFile:=CompleteArchivFileName(NameOfFile);
  if FileExists(NameOfFile) then begin
   frReport1.LoadPreparedReport(NameOfFile);
   if Edition<>0 then
    ChangeValue('Vydani_1','Vydani_2',IntToStr(Edition));
   case Action of
    RepTisk:
     frReport1.PrintPreparedReport('',0,true,frAll);
    RepExport:begin
     ExpPath:=ExtractFilePath(NameOfFile);
     frReport1.ExportTo(frHTML2Export1,ExpPath+
      ChangeFileExt(ExtractFileName(NameOfFile), '.'+FExtHtml));
     frReport1.ExportTo(frTextExport1,ExpPath+
      ChangeFileExt(ExtractFileName(NameOfFile), '.'+FExtTxt));
     frReport1.ExportTo(frRTFExport1,ExpPath+
      ChangeFileExt(ExtractFileName(NameOfFile), '.'+FExtRtf));
     frReport1.ExportTo(frCSVExport1,ExpPath+
      ChangeFileExt(ExtractFileName(NameOfFile), '.'+FExtCsv));
     frReport1.ExportTo(frJPEGExport1,ExpPath+
      ChangeFileExt(ExtractFileName(NameOfFile), '.'+FExtJPG));
    end;
   else
    frReport1.ModifyPrepared:=false;
    frReport1.PreviewButtons:=frReport1.PreviewButtons-[pbSave,pbLoad];
    frReport1.ShowPreparedReport;
   end;
  end
  else ShowMessage('The file does not exist "'+NameOfFile+'"');
 end;
begin
 inherited;
 DirectCallStatus:=false;
 if trim(NameOfFile)='' then begin
  if ArchivDirIsOK(True) then begin
   OpenDialogUT.InitialDir:=ArchivDir;
   OpenDialogUT.Filter := 'Files of saved prints|*.'+FExtRpt{'.frp'};
   OpenDialogUT.FileName:='';
   OpenDialogUT.DefaultExt:=FExtRpt{'.frp'};
   if OpenDialogUT.Execute then NameOfFile:=OpenDialogUT.FileName;
  end;
 end;
 if trim(NameOfFile)<>'' then ActionProc;
 DirectCallStatus:=true;
end;