Пример #1
0
        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);
        }
Пример #2
0
        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);
        }
Пример #3
0
        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);
        }