Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

OnStartPrint, OnEndPrint, OnNewPage, PageCount Example

The following code illustrates how to create a progress indicator, which appears as an independent form with a TProgressBar control on it. The caption of this form contains the indicator string. The TProgressBar control is used as a graphic progress indicator.

Delphi
// Opens the indicator form
// This procedure is an event handler of the
// TdxComponentPrinter OnStartPrint event
procedure TForm1.dxComponentPrinter1StartPrint(Sender: TObject; AReportLink: TBasedxReportLink);
begin
  Form2 := TForm2.Create(Application);
  Form2.Show;
end;
// Closes the indicator form
// This procedure is an event handler of the
// TdxComponentPrinter OnEndPrint event
procedure TForm1.dxComponentPrinter1EndPrint(Sender: TObject; AReportLink: TBasedxReportLink);
begin
  Form2.Close;
end;
// Repaints the indicator form on screen
// This procedure is an event handler of the
// TdxComponentPrinter OnNewPage event
procedure TForm1.dxComponentPrinter1NewPage(Sender: TObject; AReportLink: TBasedxReportLink; APageIndex: Integer; var ACancel: Boolean);
begin
  // Creates an indicator string
  Form2.Caption := 'Printing page '+ IntToStr(APageIndex) + ' of '+
  IntToStr(dxComponentPrinter1Link1.PageCount) + ' pages';
  // Calculates position of the graphic progress indicator
  Form2.ProgressBar1.Position := Round(APageIndex / dxComponentPrinter1Link1.PageCount*100);
  // Repaints the indicator form on screen
  Form2.Repaint;
end;

This code provides the following progress indicator: