
(*
 Delphi Object and Component Reference
# {bmc bm18.BMP} {bmc bm9.BMP} OnKeyDown, Abort, Printing example
The following code aborts a print job if the user presses Esc. Note that you should set KeyPreview to true to ensure that the OnKeyDown event handler of Form1 is called.
*) 
void __fastcall TForm1::FormKeyDown(TObject *Sender, WORD &Key, TShiftState Shift)
{
  if (Key == VK_ESCAPE && Printer()->Printing)
  {
    Printer()->Abort();
    MessageDlg("Printing aborted", mtInformation, 
               TMsgDlgButtons() << mbOK,0);
  }
} 
