Пример #1
0
        public static Bitmap CaptureHandle(IntPtr hWnd)
        {
            Bitmap bitmap = null;

            try
            {
                Rectangle rect   = Win32Helper.GetWindowRect(hWnd);
                Graphics  g_hwnd = Graphics.FromHwnd(hWnd);
                bitmap = new Bitmap(rect.Width, rect.Height, g_hwnd);
                Graphics g_bitmap = Graphics.FromImage(bitmap);
                g_bitmap.CopyFromScreen(rect.X, rect.Y, 0, 0,
                                        rect.Size, CopyPixelOperation.SourceCopy);
                g_bitmap.Dispose();
                g_hwnd.Dispose();
            }
            catch (Exception exp)
            {
                throw exp;
            }

            return(bitmap);
        }
Пример #2
0
 private void ShowErrorMessage(string message)
 {
     Win32Helper.BringWindowToTop(this.Handle);
     Win32Helper.SetForegroundWindow(this.Handle);
     MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
 }