How to determine whether the user of Delphi ReportMachine point in the Print dialog box "OK" or "Cancel"

Recently encountered a problem when doing a print function, ReportMachine (hereinafter referred to as RM) customers when batch printing, in the case of ShowPrintDialog to True, if the first one eliminated, meaning that customers want to cancel printing, but to cancel a lot of trouble one by one, so we have to determine whether the user points the printer window cancel "button."

From the property point of view, there is no useful properties found only in the event down the article. The principle is the definition of a global variable to False, change variables after generating print event in RM property is True, after PrintReport execution judge this variable, if the variable or to False describes the user ultimately does not print, you can quit, otherwise continue print. In RM XE10 has OnBeginPrintPage event can be judged, but D7 without this event, there BeforePrintBand, under PrintReportEvent can try, I made XE10 code for your reference, the same principle D7

TPubData1.RMReport1BeginPrintPage Procedure (aCanvas: TCanvas; aPrintRect: TRect;
  aScaleX, aScaleY: Double);
the begin
  GV_PrintDoc: = True; // this variable to True means that the user determines the print
end;

TForm_ExpressBill.ActionPrintExecute Procedure (Sender: TObject);
var
  VTMP: String;
the begin
  Inherited;
 PubData1.RMReport1.ShowPrintDialog: = True; // settings window should pop up each time the printer before printing
  the try
    with QueryList do
    the begin
      First;
      the while do not Eof // start batch printing
      begin
        PubData1.RMReport1.LoadFromBlobField (TBlobField (QueryFormat.FieldByName ( 'PFormat'))); // load print format
        PubData1.RMReport1.DoublePass: = True;
        IF PubData1.RMReport1.PrepareReport generating the then //
        begin

          PubData1.RMReport1.PrintReport; // start printing, but the printer settings window will pop up first

          if not GV_PrintDoc then // here is the key, this variable to determine if the user does not point to determine, not printed here quit
            Break;
          PubData1.RMReport1.ShowPrintDialog: = False; // Since the user selects a print first, then do not back pop-up setting window of the
        End;
        the Next;
      End;
    End;
    MessageDlg ( 'express list have all been sent to the printer!', mtInformation, [MBOK], 0);
  the except
    ON E: Exception do
    the begin
      MessageDlg ( 'express a single print failure reason! is: '+ # 10 + # 13 is e.Message, mtWarning, [MBOK], 0);
    End;
  End;
  GV_PrintDoc: = False;
End;

Guess you like

Origin blog.csdn.net/victor_yang/article/details/87912266