public static SafeDC CreateCompatibleDC(SafeDC hdc) { SafeDC safeDC = null; try { IntPtr hdc2 = IntPtr.Zero; if (hdc != null) { hdc2 = hdc.handle; } safeDC = SafeDC.NativeMethods.CreateCompatibleDC(hdc2); if (safeDC == null) { HRESULT.ThrowLastError(); } } finally { if (safeDC != null) { safeDC._created = true; } } if (safeDC.IsInvalid) { safeDC.Dispose(); throw new SystemException("Unable to create a device context from the specified device information."); } return(safeDC); }
public static SafeDC CreateDC(string deviceName) { SafeDC dc = null; try { // Should this really be on the driver parameter? dc = NativeMethods.CreateDC(deviceName, null, IntPtr.Zero, IntPtr.Zero); } finally { if (dc != null) { dc._created = true; } } if (dc.IsInvalid) { dc.Dispose(); throw new SystemException("Unable to create a device context from the specified device information."); } return(dc); }
public static SafeDC CreateDC(string deviceName) { SafeDC safeDC = null; try { safeDC = SafeDC.NativeMethods.CreateDC(deviceName, null, IntPtr.Zero, IntPtr.Zero); } finally { if (safeDC != null) { safeDC._created = true; } } if (safeDC.IsInvalid) { safeDC.Dispose(); throw new SystemException("Unable to create a device context from the specified device information."); } return(safeDC); }