예제 #1
0
 public static Standard.SafeDC CreateCompatibleDC(Standard.SafeDC hdc)
 {
     Standard.SafeDC edc = null;
     try
     {
         IntPtr zero = IntPtr.Zero;
         if (hdc != null)
         {
             zero = hdc.handle;
         }
         edc = NativeMethods.CreateCompatibleDC(zero);
         if (edc == null)
         {
             Standard.HRESULT.ThrowLastError();
         }
     }
     finally
     {
         if (edc != null)
         {
             edc._created = true;
         }
     }
     if (edc.IsInvalid)
     {
         edc.Dispose();
         throw new SystemException("Unable to create a device context from the specified device information.");
     }
     return(edc);
 }
예제 #2
0
 public static Standard.SafeDC CreateDC(string deviceName)
 {
     Standard.SafeDC edc = null;
     try
     {
         edc = NativeMethods.CreateDC(deviceName, null, IntPtr.Zero, IntPtr.Zero);
     }
     finally
     {
         if (edc != null)
         {
             edc._created = true;
         }
     }
     if (edc.IsInvalid)
     {
         edc.Dispose();
         throw new SystemException("Unable to create a device context from the specified device information.");
     }
     return(edc);
 }