public MoveWindowCommand() { initialState = new tagWINDOWINFO(); initialState.cbSize = (uint)Marshal.SizeOf(initialState); GetWindowInfo(hWnd, ref initialState); int safeDistance = DesktopSnapshotCommand.DefaultRect.Width + 50; if (initialState.rcWindow.left < safeDistance) { Execution.ExecutionEventLog.RecordStatus("Moving the test console window to upper-middle for Visual Verification stability - Sorry for the inconvenience."); MoveWindow(hWnd, safeDistance, 200, initialState.rcWindow.right - initialState.rcWindow.left, initialState.rcWindow.bottom - initialState.rcWindow.top, true); UpdateWindow(hWnd); } }
private static bool Report(int hwnd, int lParam) { IntPtr ptr = new IntPtr(hwnd); tagWINDOWINFO info = new tagWINDOWINFO(); GetWindowInfo(ptr, ref info); if (IsWindowVisible(ptr) && !IsIconic(ptr) && info.cxWindowBorders > 0 && info.cyWindowBorders > 0) { string title = GetText(new IntPtr(hwnd)); if (title != "") { WindowSpec spec = new WindowSpec(); spec.Caption = title; spec.Hwnd = ptr; spec.Info = info; Bitmap bm = GetWindowPreview(spec); BitmapImage bi = ConvertBitmapToBitmapImage(bm); TransformedBitmap tb = new TransformedBitmap(); tb.BeginInit(); tb.Source = bi; double ratio = bi.Height / bi.Width; double newHeight = 150 * ratio; double scaleX = 150 / bi.Width; double scaleY = newHeight / bi.Height; ScaleTransform transform = new ScaleTransform(scaleX, scaleY); tb.Transform = transform; tb.EndInit(); spec.Preview = tb; WindowNames.Add(spec); } } return(true); }
public static extern bool GetWindowInfo(IntPtr hwnd, ref tagWINDOWINFO pwi);
private static bool Report(int hwnd, int lParam) { IntPtr ptr = new IntPtr(hwnd); tagWINDOWINFO info = new tagWINDOWINFO(); GetWindowInfo(ptr, ref info); if (IsWindowVisible(ptr) && !IsIconic(ptr) && info.cxWindowBorders > 0 && info.cyWindowBorders > 0) { string title = GetText(new IntPtr(hwnd)); if (title != "") { WindowSpec spec = new WindowSpec(); spec.Caption = title; spec.Hwnd = ptr; spec.Info = info; Bitmap bm = GetWindowPreview(spec); BitmapImage bi = ConvertBitmapToBitmapImage(bm); TransformedBitmap tb = new TransformedBitmap(); tb.BeginInit(); tb.Source = bi; double ratio = bi.Height / bi.Width; double newHeight = 150 * ratio; double scaleX = 150 / bi.Width; double scaleY = newHeight / bi.Height; ScaleTransform transform = new ScaleTransform(scaleX, scaleY); tb.Transform = transform; tb.EndInit(); spec.Preview = tb; WindowNames.Add(spec); } } return true; }
public static extern bool GetWindowInfo(int hWnd, out tagWINDOWINFO info);