|
Overview |
|
|
|
Group |
|
|
|
Quick Info
Windows NT
| Yes
| Win95
| Yes
| Win32s
| No
| Import Library
| winspool.lib
| Header File
| winspool.h
| Unicode
| WinNT
| Platform Notes
| None
|
|
|
DocumentProperties
The DocumentProperties function retrieves or modifies printer initialization information or displays
a printer-configuration dialog box for the specified printer.
LONG DocumentProperties(
HWND hWnd,
| // handle to window that displays dialog box
| HANDLE hPrinter,
| // handle to printer object
| LPTSTR pDeviceName,
| // pointer to device name
| PDEVMODE pDevModeOutput,
| // pointer to modified device mode structure
| PDEVMODE pDevModeInput,
| // pointer to original device mode structure
| DWORD fMode
| // mode flag
| );
|
|
Parameters
hWnd
Identifies the parent window of the printer-configuration dialog box.
hPrinter
Identifies a printer object.
pDeviceName
Points to a null-terminated string that specifies the name of the device for
which the printer-configuration dialog box should be displayed.
pDevModeOutput
Points to a DEVMODE structure that receives the printer configuration data specified by the user.
pDevModeInput
Pointer to a DEVMODE structure that the operating system uses to initialize the dialog box
controls.
This parameter is only used if the DM_IN_BUFFER flag is set in the fMode parameter. If DM_IN_BUFFER is not set, the operating system uses the
printer's default DEVMODE.
fMode
Specifies a mask of values that determines the operations the function
performs. If this parameter is zero, the DocumentProperties function returns the number of bytes required by the printer driver's DEVMODE data structure. Otherwise, use one or more of the following constants to
construct a value for this parameter; note, however, that in order to change the
print settings, an application must specify at least one input value and one
output value:
Value
| Meaning
| DM_IN_BUFFER
| Input value. Before prompting, copying, or updating, the function merges the
printer driver's current print settings with the settings in the DEVMODE structure specified by the pDevModeInput parameter. The function updates the structure only for those members
specified by the DEVMODE structure's dmFields member. This value is also defined as DM_MODIFY. In cases of conflict during
the merge, the settings in the DEVMODE structure specified by pDevModeInput override the printer driver's current print settings.
| DM_IN_PROMPT
| Input value. The function presents the printer driver's Print Setup dialog box
and then changes the settings in the printer's DEVMODE data structure to those values specified by the user. This value is also
defined as DM_PROMPT.
| DM_OUT_BUFFER
| Output value. The function writes the printer driver's current print settings,
including private data, to the DEVMODE data structure specified by the pDevModeOutput parameter. The caller must allocate a buffer sufficiently large to contain
the information. If the bit DM_OUT_BUFFER sets is clear, the pDevModeOutput parameter can be NULL. This value is also defined as DM_COPY.
|
Return Values
If the fMode parameter is zero, the return value is the size of the buffer required to
contain the printer driver initialization data. Note that this buffer can be
larger than a DEVMODE structure if the printer driver appends private data to the structure.
If the function displays the initialization dialog box, the return value is
either IDOK or IDCANCEL, depending on which button the user selects.
If the function does not display the dialog box and is successful, the return
value is IDOK.
If the function fails, the return value is less than zero.
Remarks
The printer object handle identified by the hPrinter parameter can be obtained by calling the OpenPrinter function.
The string pointed to by the pDeviceName parameter can be obtained by calling the GetPrinter function.
Note that the DEVMODE structure actually used by a printer driver contains the device-independent
part (as defined above) followed by a driver-specific part that varies in size
and content with each driver and driver version. Because of this driver
dependence, it is very important for applications to query the driver for the correct
size of the DEVMODE structure before allocating a buffer for it.
To make changes to print settings that are local to an application, an
application should follow these steps:
- Get the number of bytes required for the full DEVMODE structure by calling DocumentProperties and specifying zero in the fMode parameter.
- Allocate memory for the full DEVMODE structure.
- Get the current printer settings by calling DocumentProperties. Pass a pointer to the DEVMODE structure allocated in Step 2 as the pDevModeOutput parameter and specify the DM_OUT_BUFFER value.
- Modify the appropriate members of the returned DEVMODE structure and indicate which members were changed by setting the
corresponding bits in the dmFields member of the DEVMODE.
- Call DocumentProperties and pass the modified DEVMODE structure back as both the pDevModeInput and pDevModeOutput parameters and specify both the DM_IN_BUFFER and DM_OUT_BUFFER values (which
are combined using the OR operator).
The DEVMODE structure returned by the third call to DocumentProperties can be used as an argument in a call to the CreateDC function.
To create a handle to a printer-device context using the current printer
settings, you only need to call DocumentProperties twice, as described above. The first call gets the size of the full DEVMODE and the second call initializes the DEVMODE with the current printer settings. Pass the initialized DEVMODE to CreateDC to obtain the handle to the printer device context.
See Also
AdvancedDocumentProperties, CreateDC, DEVMODE, GetPrinter, OpenPrinter
| Last news from Greatis Software |
 |
|
Nostalgia .Net |
|
.Net is powerful, but not all-powerful, so sometimes we need to use Win32 API for our .Net applications. It's simple enough with Platform Invoke if you have Win32 skill, but we do not always have time to dig the ancient documentation, declare the special types that are compatible with Win32, find the values of the Win32's constants and so on. Nostalgia .Net offers several simple-to-use classes, and components that will allow you to forget about the headache of Win32 and just use the power of Win32 in your application the same way as you use the native. Net classes. More » |
| Recommended software for developers |
 |
|
Ultimate Pack |
|
Component pack for Delphi and C++ Builder that contains runtime form designer, runtime object inspector, print suite and much more for the very special price. More » |
 |
|
Form Designer .Net |
|
Unique runtime form design solution that allows to edit any form in .Net WinForms application at runtime with full source codes for only 300 euro! More » |
 |
|
Print Suite .Net |
|
Print Suite .Net is a set of components for easy printing texts, images and grids from your WinForms applications. Full C# source codes are available More » |
 |
|
Gradient Controls .Net |
|
Gradient Controls .Net offers controls with gradient background feature. Labels, panels and so on... Full C# source codes are available More » |
 |
|
Greatis iGrid |
|
iGrid plots drawing grid right over your desktop, so you can use it everywhere, with any drawing application without any special plugins for different graphic editors. More » |
All the contacts and projectsDmitry Vasiliev (just.dmitry)
Related LinksSoftware for Visual Studio .NET developers Software for Delphi and C++ Builder developers Software for Visual Basic 6 developers Delphi Tips&Tricks MegaDetailed.NET More Online Helps Win32 Programmer's Reference Win32 Multimedia Programmer's Reference OLE Programmer's Reference Microsoft Windows Pen API Programmer's Reference Microsoft Windows Sockets 2 Reference Microsoft Windows Telephony API (TAPI) Programmer's Reference Unix Manual Pages
|