Gdi32CreateDC Method

Creates a device context (DC) for a device using the specified name.

Definition

Namespace: DevCase.Win32.NativeMethods
Assembly: DevCase.net48 (in DevCase.net48.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
[DllImportAttribute("GDI32.dll", CharSet = CharSet.Ansi, BestFitMapping = false, 
	ThrowOnUnmappableChar = true, SetLastError = true)]
public static IntPtr CreateDC(
	string lpszDriver,
	string lpszDevice,
	string lpszOutput,
	IntPtr lpInitData
)

Parameters

lpszDriver  String
A pointer to a null-terminated character string that specifies either "DISPLAY" or the name of a specific display device.

For printing, we recommend that you pass to lpszDriver because GDI ignores lpszDriver for printer devices.

lpszDevice  String
A pointer to a null-terminated character string that specifies the name of the specific output device being used, as shown by the Print Manager (for example, "Epson FX-80"). It is not the printer model name. The lpszDevice parameter must be used.

To obtain valid names for displays, call EnumDisplayDevices function.

If lpszDriver is "DISPLAY" or the device name of a specific display device, then lpszDevice must be or that same device name.

If lpszDevice is , then a device context (DC) is created for the primary display device.

If there are multiple monitors on the system, calling CreateDC("DISPLAY", Nothing, Nothing, Nothing) will create a device context (DC) covering all the monitors.

lpszOutput  String
This parameter is ignored and should be set to . It is provided only for compatibility with 16-bit Windows.
lpInitData  IntPtr
A pointer to a DevMode structure containing device-specific initialization data for the device driver.

The DocumentProperties function retrieves this structure filled in for a specified device.

The lpInitData parameter must be if the device driver is to use the default initialization (if any) specified by the user.

Return Value

IntPtr
If the function succeeds, the return value is the handle to a DC for the specified device.

If the function fails, the return value is Zero.

Remarks

See Also