Skip to main content

Problem:

This illustrates how to use the Win32 Api ResetDC to adjust the page size for the printer

Resolution:

INTRODUCTION

==========

This example demonstrates the use of the Win32 SDK function call ResetDC to modify the settings of a printer between print jobs. This program uses the Net Express call-by-name routines PC_PRINTER_OPEN and PC_PRINTER_INFO to select a printer and obtain the printers Device Context Handle. This handle is then used to end the page started by PC_PRINTER_OPEN and in the call to ResetDC in order to change the printers page size to an envelope with landscape orientation. An envelope will then be printed.

SOURCE FILES:

=========

Program Files         Description

-------------------     -----------------------------------------------------------

RESETDC .CBL       Program that calls the WINAPI functions to reset the device context to print

                              an envelope.

PRNTOPEN.CPY     Copy file containing the working-storage data items referenced by the

                               PC_PRINTER_OPEN call-by-name routine.

PRNTINFO.CPY     Copy file containing the working-storage data items referenced by the

                              PC_PRINTER_INFO call-by-name routine.

DEVMODE .CPY     Copy file containing the structure used in the ResetDC call.

DEVMDE78.CPY     Copy file containing the constants for setting the fields within the device mode

                              structure.

GDI32.LIB             Import library from the Windows SDK. This file is linked into RESETDC.EXE to                                     resolve the references to the device context calls. This file is provided with

                              Net Express and can be found in the Net Express\\Base\\Lib directory.

REQUIREMENTS:

==========

This program should run in any environment which has access to at least one printer that supports envelope printing.

OPERATION:

========

Rebuild this project to create the file resetdc.exe. This is a character mode program that will display its progress to an application output window.

NOTE:

====

The file GDI32.LIB is specified under Project/Build Settings/Link/Advanced in the "Link with these LIBs" field. It must be included in any program that makes a call to these printer functions.

==========================================================

Keywords: demonstration, sample, example, demo, resetdc.zip

demo.ex

demo.me

demo.ne

Attachments:

resetdc.zip

Old KB# 4064