ComponentOne VSView 8.0
PrintDialog Method

Displays a printer selection or page setup dialog.

Syntax

[form!]VSPrinter.PrintDialog(DialogType As PrintDialogSettings)

Remarks

This method displays a standard Print, Printer Setup, or Page Setup dialog, depending on the setting of the DialogType parameter.

Valid settings for the DialogType parameter are:

Constant

Value

Description

pdPrinterSetup

0

Displays a Printer Setup dialog. This dialog is normally used before the document is created, to select the target printer, paper size, and orientation.

pdPageSetup

1

Displays a Page Setup dialog. This dialog is normally used before the document is created, to select margins, paper size, and orientation.

pdPrint

2

Displays a Print dialog. This dialog is used after the document is ready, to select the range of pages to print and number of copies. (If the document is empty, this parameter displays a Printer Setup dialog instead).

pdGetFromPage

100

Retrieves the first page in the range selected by the user from the last Print dialog (this setting does not display a dialog).

pdGetToPage

101

Retrieves the last page in the range selected by the user from the last Print dialog (this setting does not display a dialog).

pdGetToFile

102

Retrieves a Boolean value that indicates whether the user selected the Print To File button on the last Print dialog (this setting does not display a dialog).

The picture below shows the Print, Printer Setup, and Page Setup dialogs. Note that these dialogs are provided by the operating system and their appearance may vary.

When used with the settings that display dialogs, PrintDialog returns True if the user clicked OK to accept the changes and False if the user clicked Cancel to dismiss the dialog.

Changes made by the user through the dialogs are reflected in the control (for example, device, paper size, orientation, margins, copies, and so on). If the DefaultDevice property is set to True, the device also becomes the default for other Windows applications. However, these changes are not automatically reflected in the current preview document. The document retains the original formatting and you need to regenerate it to apply the changes made by the user.

If the document is long and generating it is time-consuming, you may want to cache the values of the Device, PaperSize, Orientation, and Margin properties and regenerate the document only if one of them was changed.

The code below shows typical uses of the PrintDialog method:

' ** Print Dialog: select printer, pages, copies

If vp.PageCount = 0 Then

  MsgBox "No document: using Printer Setup Dialog."

End If

If vp.PrintDialog(pdPrint) Then

  MsgBox "You chose to print " & vp.Copies & _

          " copies of pages " & vp.PrintDialog(pdGetFromPage) & _

         " through " & vp.PrintDialog(pdGetToPage) & _

         " (ToFile is " & vp.PrintDialog(pdGetToFile) & ")." & vbCrLf

End If

 

'  ** Page Setup Dialog: select margins, paper size, orientation

If vp.PrintDialog(pdPageSetup) Then

  MsgBox "Device is " & vp.Device & ". " & _

           "Paper size is " & vp.PaperSize & ". " & _

           "Orientation is " & vp.Orientation & ".  " & _

          "Margins are " & vp.MarginLeft & ", " & vp.MarginTop & ", " & _

          vp.MarginRight & ", and " & vp.MarginBottom & "." & vbCrLf

End If

 

'  ** Printer Setup Dialog : select printer, paper size, orientation

If vp.PrintDialog(pdPrinterSetup) Then

  MsgBox "Device is " & vp.Device & ". " & _

         "Paper size is " & vp.PaperSize & ". " & _

         "Orientation is " & vp.Orientation & "."

End If

 

 


Copyright (c) GrapeCity, inc. All rights reserved.

Product Support Forum  |  Documentation Feedback