Microsoft KB Archive/78165

= How to Specify Num of Copies w/ Common Dialog or Escape API =

Article ID: 78165

Article Last Modified on 11/18/2003

-

APPLIES TO


 * Microsoft Visual Basic 2.0 Professional Edition
 * Microsoft Visual Basic 3.0 Professional Edition
 * Microsoft Visual Basic 1.0 Standard Edition

-



This article was previously published under Q78165



SUMMARY
You can use the Common Dialog in the Professional Edition of Visual Basic version 2.0 or 3.0, or you can call the Windows API Escape function in other versions to tell the Windows Print Manager how many copies of a document you want to print.



MORE INFORMATION
The Windows API constant SETCOPYCOUNT (value 17) can be used as an argument to the Escape function to specify the number of uncollated copies of each page for the printer to print.

The arguments for Escape are as follows:

r% = Escape(hDC, SETCOPYCOUNT, Len(Integer), lpNumCopies, lpActualCopies) Parameter         Type/Description

hDC               hDC. Identifies the device context. Usually referenced by Printer.hDC.

lpNumCopies       Long pointer to integer (not ByVal). Point to a                  short-integer value that contains the number of                   uncollated copies to print.

lpActualCopies    Long pointer to integer (not ByVal). Points to a                  short integer value that will receive the number of                   copies that where printed. This may be less than the number requested if the requested number is                  greater than the device's maximum copy count.

The return value specifies the outcome of the escape -- 1 if the escape is successful, a negative number if the escape is not successful, or zero if the escape is not supported.

The following example code demonstrates how to print three copies of a line of text on the printer. To re-create this example, choose New Project from the Visual Basic File menu. Then add a command button to the form and paste the following code into the appropriate event procedures:

REM Below is GLOBAL.BAS:

' The following Declare statement must be typed on one, single line:

Declare Function Escape% Lib &quot;GDI&quot; (ByVal hDc%, ByVal nEsc%, ByVal nLen%,  lpData%, lpOut%)

REM  Below is the click procedure for a command button on Form1:

Sub Command1_Click Const SETCOPYCOUNT = 17 Printer.Print &quot;&quot; x% = Escape(Printer.hDC, SETCOPYCOUNT, Len(I%), 3, actual%) Printer.Print &quot; Printing three copies of this&quot; Printer.EndDoc End Sub

Additional query words: 2.00 3.00

Keywords: KB78165

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.