#include “BlackIceDEVMODE.h”
DWORD AddPaperSize(BlackIceDEVMODE* pDevMode, LPCTSTR szPaperName, DWORD dwWidth, DWORD dwHeight, DWORD dwUnit);
Description
Adds a new paper to the paper list of the printer. This functions adds the new paper list to the registry of the current user. The printing application must be restarted for the changes to take effect.
Paper sizes added using the AddPaperSize function 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 papers 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 new paper size.
DWORD dwWidth:
Width of the new paper size. The dwUnit parameter specifies the units.
DWORD dwHeight:
Height of the new paper size. The dwUnit parameter specifies the units.
DWORD dwUnit:
Specifies the units of dwWidth and dwHeight, can be one of the following values:
0: hundredths of inches
1: teths of millimeters
2: pixels
Return value
On success: The windows paper code of the new added paper that can be used with the SetPaperSize function.
The function returns 0, if an error happens or a paper with the given name already exists.
Programming Notes
None
Code Example
// load the DEVMODE structure
BlackIceDEVMODE* pDevMode = LoadBlackIceDEVMODE(szPrinterName);
// add or modify paper size
DWORD dwPaperCode = AddPaperSize(pDevMode, _T("Test Paper"), 1000, 1000, 1);
if (dwPaperCode == 0)
{
dwPaperCode = ModifyPaperSize(pDevMode, _T("Test Paper"),
_T("Test Paper"), 1000, 1000, 1);
}
// 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);