internal static void AddTabbedThumbnail(TabbedThumbnail preview) { // Create a TOP-LEVEL proxy window for the user's source window/control TaskbarWindow taskbarWindow = null; // get the TaskbarWindow for UIElement/WindowHandle respectfully. if (preview.WindowHandle == IntPtr.Zero) { taskbarWindow = GetTaskbarWindow(preview.WindowsControl, TaskbarProxyWindowType.TabbedThumbnail); } else { taskbarWindow = GetTaskbarWindow(preview.WindowHandle, TaskbarProxyWindowType.TabbedThumbnail); } //create taskbar, or set its TabbedThumbnail if (taskbarWindow == null) { taskbarWindow = new TaskbarWindow(preview); _taskbarWindowList.Add(taskbarWindow); } else if (taskbarWindow.TabbedThumbnail == null) { taskbarWindow.TabbedThumbnail = preview; } // Listen for Title changes preview.TitleChanged += new EventHandler(thumbnailPreview_TitleChanged); preview.TooltipChanged += new EventHandler(thumbnailPreview_TooltipChanged); // Get/Set properties for proxy window IntPtr windowHandle = taskbarWindow.WindowToTellTaskbarAbout; // Register this new tab and set it as being active. TaskbarList.Instance.RegisterTab(windowHandle, preview.ParentWindowHandle); TaskbarList.Instance.SetTabOrder(windowHandle, IntPtr.Zero); TaskbarList.Instance.SetTabActive(windowHandle, preview.ParentWindowHandle, 0); // We need to make sure we can set these properties even when running with admin TabbedThumbnailNativeMethods.ChangeWindowMessageFilter( TabbedThumbnailNativeMethods.WmDwmSendIconicThumbnail, TabbedThumbnailNativeMethods.MsgfltAdd); TabbedThumbnailNativeMethods.ChangeWindowMessageFilter( TabbedThumbnailNativeMethods.WmDwmSendIconicLivePreviewBitmap, TabbedThumbnailNativeMethods.MsgfltAdd); // BUG: There should be somewhere to disable CustomWindowPreview. I didn't find it. TabbedThumbnailNativeMethods.EnableCustomWindowPreview(windowHandle, true); // Make sure we use the initial title set by the user // Trigger a "fake" title changed event, so the title is set on the taskbar thumbnail. // Empty/null title will be ignored. thumbnailPreview_TitleChanged(preview, EventArgs.Empty); thumbnailPreview_TooltipChanged(preview, EventArgs.Empty); // Indicate to the preview that we've added it on the taskbar preview.AddedToTaskbar = true; }
internal void AddTabbedThumbnail(TabbedThumbnail preview) { // Create a TOP-LEVEL proxy window for the user's source window/control TaskbarWindow taskbarWindow = null; if (preview.WindowHandle != IntPtr.Zero) { taskbarWindow = GetTaskbarWindow(preview.WindowHandle, TaskbarProxyWindowType.TabbedThumbnail); } else { taskbarWindow = GetTaskbarWindow(preview.WindowsControl, TaskbarProxyWindowType.TabbedThumbnail); } if (taskbarWindow == null) { taskbarWindow = new TaskbarWindow(preview); taskbarWindowList.Add(taskbarWindow); } else if (taskbarWindow.TabbedThumbnail == null) { taskbarWindow.TabbedThumbnail = preview; } // preview.TaskbarWindow = taskbarWindow; // Listen for Title changes preview.TitleChanged += new EventHandler(thumbnailPreview_TitleChanged); preview.TooltipChanged += new EventHandler(thumbnailPreview_TooltipChanged); // Get/Set properties for proxy window IntPtr hwnd = taskbarWindow.WindowToTellTaskbarAbout; // Register this new tab and set it as being active. TaskbarManager.Instance.TaskbarList.RegisterTab(hwnd, preview.ParentWindowHandle); TaskbarManager.Instance.TaskbarList.SetTabOrder(hwnd, IntPtr.Zero); TaskbarManager.Instance.TaskbarList.SetTabActive(hwnd, preview.ParentWindowHandle, 0); // We need to make sure we can set these properties even when // running with admin TabbedThumbnailNativeMethods.ChangeWindowMessageFilter(TabbedThumbnailNativeMethods.WM_DWMSENDICONICTHUMBNAIL, TabbedThumbnailNativeMethods.MSGFLT_ADD); TabbedThumbnailNativeMethods.ChangeWindowMessageFilter(TabbedThumbnailNativeMethods.WM_DWMSENDICONICLIVEPREVIEWBITMAP, TabbedThumbnailNativeMethods.MSGFLT_ADD); TabbedThumbnailNativeMethods.EnableCustomWindowPreview(hwnd, true); // Make sure we use the initial title set by the user // Trigger a "fake" title changed event, so the title is set on the taskbar thumbnail. // Empty/null title will be ignored. thumbnailPreview_TitleChanged(preview, EventArgs.Empty); thumbnailPreview_TooltipChanged(preview, EventArgs.Empty); // Indicate to the preview that we've added it on the taskbar preview.AddedToTaskbar = true; }