Esempio n. 1
0
        public static void DrawAdorner(IntPtr hwnd, Action<Graphics, Size> drawMethod = null)
        {
            var windowRect = new RECT(0, 0, 0, 0);
            NativeMethods.GetWindowRect(hwnd, ref windowRect);

            var parentWindow = NativeMethods.GetParent(hwnd);
            IntPtr windowDC;
            windowDC = NativeMethods.GetWindowDC(hwnd);
            if (windowDC == IntPtr.Zero) return;

            if (drawMethod == null)
                drawMethod = DrawDefaultAdorner;

            try
            {
                using (var g = Graphics.FromHdc(windowDC, hwnd))
                    drawMethod(g, windowRect.Size);
            }
            finally { NativeMethods.ReleaseDC(hwnd, windowDC); }
        }
Esempio n. 2
0
 public static extern IntPtr GetWindowRect(IntPtr hwnd, ref RECT rc);