Back to Devexpress

TdxPrintDialog Class

vcl-dxprndlg.md

latest4.3 KB
Original Source

TdxPrintDialog Class

A non-visual component designed to display a custom Print dialog.

Declaration

delphi
TdxPrintDialog = class(
    TcxCustomComponent
)

Remarks

Use the TdxPrintDialog component only if you need to implement custom behavior for the standard Print dialog.

Important

The TdxPrintDialog component does not affect the built-in Print dialog available for the TdxComponentPrinter component and control-specific report links.

Main API Members

The list below outlines key members of the TdxPrintDialog class that allow you to configure and display the Print dialog.

Printer Settings

CollateSpecifies if the page collate option is enabled.CopiesSpecifies the number of printed copies.MinRange | MaxRangeSpecify the target range of printed pages.OptionsEnabledSpecifies active Boolean printer options (print to file, all pages, current page, etc.).OptionsVisibleSpecifies visible UI elements.PageCount | PageNums | PageRanges | PagesSpecify page range-related settings for the Print dialog.PrintToFileSpecifies if the target document is printed to a file.

Print Dialog Behavior APIs

Execute

Displays the Print dialog using the current settings.

This function returns True if a user clicks the Print button to close the dialog.

OnCloseAllows you to respond to Print dialog close operations.OnPageSetup

Allows you to respond to clicks on the Page Setup… button.

Handle this event to implement Page Setup dialog functionality. If OnPageSetup is unhandled, the Page Setup… button is disabled in the Print dialog.

OnShowAllows you to execute custom code before the Print dialog appears (following an Execute function call).

Code Example: Display the Print Dialog and Print Content

The following code example displays the Print dialog and prints control content using the current report link:

delphi
uses
  dxPSCore, // Declares the TdxComponentPrinter class
  dxPrnDlg; // Declares the TdxPrintDialog component
// ...

procedure TMyForm.dxSpreadSheetShowPrintFormExecute(Sender: TObject);
begin
  if dxPrintDialog1.Execute() then // Displays the Print dialog
    dxComponentPrinter1.Print(False, nil); // Prints content using the current report link
end;
cpp
#include "dxPSCore.hpp" // Declares the TdxComponentPrinter class
#include "dxPrnDlg.hpp" // Declares the TdxPrintDialog component

// Add the following linker directives to the corresponding CPP source file:
#pragma link "dxPSCore" // Required to use dxPSCore.hpp declarations
#pragma link "dxPrnDlg" // Required to use dxPrnDlg.hpp declarations

void __fastcall TMyForm::dxSpreadSheetShowPrintFormExecute(TObject *Sender)
{
  if(dxPrintDialog1->Execute()) // Displays the Print dialog
    dxComponentPrinter1->Print(false, nullptr); // Prints content using the current report link
}

Inheritance

TObject TPersistent TComponent TcxCustomComponent TdxPrintDialog

See Also

dxPrintDevice Global Function

TdxPrintDialog Members

dxPrnDlg Unit