public Monitor() { InitializeComponent(); DefaultNonClickTransparencyKey = this.TransparencyKey; DefaultBorderStyle = this.FormBorderStyle; ThumbnailPanel = new ThumbnailPanel { Location = Point.Empty, Dock = DockStyle.Fill }; Controls.Add(ThumbnailPanel); this.KeyPreview = true; WindowSeeker = new TaskWindowSeeker() { OwnerHandle = this.Handle, SkipNotVisibleWindows = true }; //分水岭 taskIcon = new NotifyIcon { Text = "窗体监控", Icon = Icon, Visible = true, ContextMenuStrip = MenuStrip }; taskIcon.DoubleClick += new EventHandler(TaskIcon_doubleclick); ContextMenuStrip = MenuStrip;//传递指针进来构造的,不给右键菜单 ShowInTaskbar = true; }
/// <summary> /// Sets a new thumbnail. /// </summary> /// <param name="handle">Handle to the window to clone.</param> /// <param name="region">Region of the window to clone or null.</param> public void SetThumbnail(WindowHandle handle, ThumbnailRegion region) { try { CurrentThumbnailWindowHandle = handle; ThumbnailPanel.SetThumbnailHandle(handle, region); //Set aspect ratio (this will resize the form), do not refresh if in fullscreen SetAspectRatio(ThumbnailPanel.ThumbnailPixelSize, true); } catch (Exception ex) { ThumbnailError(ex, false, "无法创建缩略图"); ThumbnailPanel.UnsetThumbnail(); } }
public Monitor(IntPtr h) { InitializeComponent(); DefaultNonClickTransparencyKey = this.TransparencyKey; DefaultBorderStyle = this.FormBorderStyle; ThumbnailPanel = new ThumbnailPanel { Location = Point.Empty, Dock = DockStyle.Fill }; Controls.Add(ThumbnailPanel); this.KeyPreview = true; WindowSeeker = new TaskWindowSeeker() { OwnerHandle = this.Handle, SkipNotVisibleWindows = true }; WindowHandle w = new WindowHandle(h); this.SetThumbnail(w, null); }
/// <summary> /// Disables the cloned thumbnail. /// </summary> public void UnsetThumbnail() { CurrentThumbnailWindowHandle = null; ThumbnailPanel.UnsetThumbnail(); KeepAspectRatio = false; }