public void SetHdevmode(IntPtr hdevmode) { IntSecurity.AllPrintingAndUnmanagedCode.Demand(); if (hdevmode == IntPtr.Zero) { throw new ArgumentException(System.Drawing.SR.GetString("InvalidPrinterHandle", new object[] { hdevmode })); } SafeNativeMethods.DEVMODE mode = (SafeNativeMethods.DEVMODE)UnsafeNativeMethods.PtrToStructure(SafeNativeMethods.GlobalLock(new HandleRef(null, hdevmode)), typeof(SafeNativeMethods.DEVMODE)); if ((mode.dmFields & 0x800) == 0x800) { this.color = mode.dmColor == 2; } if ((mode.dmFields & 1) == 1) { this.landscape = mode.dmOrientation == 2; } this.paperSize = this.PaperSizeFromMode(mode); this.paperSource = this.PaperSourceFromMode(mode); this.printerResolution = this.PrinterResolutionFromMode(mode); SafeNativeMethods.GlobalUnlock(new HandleRef(null, hdevmode)); }
public void SetHdevmode(IntPtr hdevmode) { IntSecurity.AllPrintingAndUnmanagedCode.Demand(); if (hdevmode == IntPtr.Zero) { throw new ArgumentException(System.Drawing.SR.GetString("InvalidPrinterHandle", new object[] { hdevmode })); } SafeNativeMethods.DEVMODE mode = (SafeNativeMethods.DEVMODE) UnsafeNativeMethods.PtrToStructure(SafeNativeMethods.GlobalLock(new HandleRef(null, hdevmode)), typeof(SafeNativeMethods.DEVMODE)); if ((mode.dmFields & 0x800) == 0x800) { this.color = mode.dmColor == 2; } if ((mode.dmFields & 1) == 1) { this.landscape = mode.dmOrientation == 2; } this.paperSize = this.PaperSizeFromMode(mode); this.paperSource = this.PaperSourceFromMode(mode); this.printerResolution = this.PrinterResolutionFromMode(mode); SafeNativeMethods.GlobalUnlock(new HandleRef(null, hdevmode)); }