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

Example: Abort Report Building

  • 2 minutes to read

This example demonstrates how to cancel the building of a report in response to an action by an end-user (pressing the Esc key). There is a form containing the TdxComponentPrinter component and a button. Clicking the button invokes the preview window for the report link associated with the component printer.

The code below demonstrates how to abort the building of a report when the Esc key is pressed:

Delphi
// Define the AAbortBuilding variable used as a flag indicating if

...
var
  Form1: TForm1;
  AAbortBuilding: Boolean;
implementation
...
 property to let the form receive keyboard

// variable, invoke the preview window and then restore the form's
procedure TForm1.Button4Click(Sender: TObject);
begin
  KeyPreview := True;
  AAbortBuilding := False;
  dxComponentPrinter1Link1.Preview(False);
  KeyPreview := False;
end;
// Handle the form's OnKeyDown event and set the flag according to the
// key pressed.
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
  AAbortBuilding := (Key = vk_Escape);
end;
// Once the flag variable is changed, set the report link's
// AbortBuilding property to True to indicate that the building of
// the report should be stopped and show an appropriate message.
procedure TForm1.dxComponentPrinter1GenerateReportProgress(Sender: TObject; AReportLink: TBasedxReportLink; APercentDone: Double);
begin
  if AAbortBuilding then
  begin
    AReportLink.AbortBuilding := AAbortBuilding;
'Message'
  end;
end;
See Also