ModifyPaperSizeEx

 

#include “BlackIceDEVMODE.h”

 

DWORD        ModifyPaperSizeEx(BlackIceDEVMODE* pDevMode, LPCTSTR szPaperName, LPCTSTR szNewPaperName, DWORD dwWidth, DWORD dwHeight, DWORD dwUnit, BOOL bRollPaper);

 

Description

 

Modifies an existing paper in the printer’s paper list. The function can only modify paper sizes added with the user interface or the AddPaperSize and AddPaperSizeEx API functions. It cannot modify the default paper sizes, such as A4 or Letter. The printing application must be restarted for the changes to take effect.

 

Paper sizes added using the AddPaperSize or AddPaperSizeEx functions or from the Printing Preferences dialog will be deleted when the user presses the Restore Defaults button on the Printing Preferences dialog. To add a paper size permanently for all users, the new paper size should be added to the Printer Driver’s INI files.

 

Parameters

 

BlackIceDEVMODE* pDevMode:

Pointer to the BlackIceDEVMODE structure of the printer.

 

LPCTSTR szPaperName:

Name of the existing paper size to modify.

 

LPCTSTR szNewPaperName:

The new name of the paper size.

 

DWORD dwWidth:

New width of the paper size. The dwUnit parameter specifies the units.

 

DWORD dwHeight:

New height of the paper size. The dwUnit parameter specifies the units.

 

DWORD dwUnit:

Specifies the units of dwWidth and dwHeight, which can be one of the following values:

0: hundredths of inches

1: tenths of millimeters

2: pixels

 

BOOL bRollPaper:

Specifies if the added paper size is a roll paper size. For roll paper sizes, the Printer Driver automatically cuts off the empty space below the printed page content. The dwHeight parameter will specify the maximum height of the page.

 

Return value

 

On success: The Windows paper code of the paper that was modified, which can be used with the SetPaperSize function.

The function returns 0 if an error happens, or the paper with the given name does not exist, or it is not modifiable.

 

Programming Notes

 

None

 

Code Example

 

// load the DEVMODE structure

BlackIceDEVMODE* pDevMode = LoadBlackIceDEVMODE(szPrinterName);

// add or modify paper size

DWORD dwPaperCode = AddPaperSizeEx(pDevMode, _T("Roll Paper"), 800, 3000, 1, TRUE);

if (dwPaperCode == 0)

{

  dwPaperCode = ModifyPaperSizeEx(pDevMode, _T("Roll Paper"),

    _T("Roll Paper"), 800, 3000, 1, TRUE);

}

// Set the new paper size and other settings

SetPaperSize(dwPaperCode, pDevMode);

...

// save the settings for the current user and release the structure

SaveBlackIceDEVMODE(szPrinterName, pDevMode);

ReleaseBlackIceDEVMODE(pDevMode);

// copy the current user's settings to all users on the system

CopySettingsForAllUsers(szPrinterName);