GetDC() 개인적인 메소드

private GetDC ( ) : void
리턴 void
예제 #1
0
        static DpiHelper()
        {
            // Getting the Desktop, so we shouldn't have to release this DC.
            // This could potentially throw if used in a service.
            IntPtr desktop = NativeMethods.GetDC(IntPtr.Zero);

            // Can get these in the static constructor.  They shouldn't vary window to window,
            // and changing the system DPI requires a restart.
            int pixelsPerInchX = NativeMethods.GetDeviceCaps(desktop, DeviceCap.LOGPIXELSX);
            int pixelsPerInchY = NativeMethods.GetDeviceCaps(desktop, DeviceCap.LOGPIXELSY);

            _transformToDip = Matrix.Identity;
            _transformToDip.Scale(96d / (double)pixelsPerInchX, 96d / (double)pixelsPerInchY);
            _transformToDevice = Matrix.Identity;
            _transformToDevice.Scale((double)pixelsPerInchX / 96d, (double)pixelsPerInchY / 96d);
        }
예제 #2
0
 public static Standard.SafeDC GetDC(IntPtr hwnd)
 {
     Standard.SafeDC dC = null;
     try
     {
         dC = NativeMethods.GetDC(hwnd);
     }
     finally
     {
         if (dC != null)
         {
             dC.Hwnd = hwnd;
         }
     }
     if (dC.IsInvalid)
     {
         Standard.HRESULT.E_FAIL.ThrowIfFailed();
     }
     return(dC);
 }
예제 #3
0
        public static SafeDC GetDC(IntPtr hwnd)
        {
            SafeDC dc = null;

            try
            {
                dc = NativeMethods.GetDC(hwnd);
            }
            finally
            {
                if (dc != null)
                {
                    dc.Hwnd = hwnd;
                }
            }

            if (dc.IsInvalid)
            {
                // GetDC does not set the last error...
                HRESULT.E_FAIL.ThrowIfFailed();
            }

            return(dc);
        }