public void SubmitThumbnailButtons(bool add) { int hr = -1; if (MainThread.MainWindow.IsDisposed || MainThread.MainWindow.Disposing) { return; } if (_taskbarList != null && _buttons.Count > 0) { if (add || !_addedOnce) { hr = _taskbarList.ThumbBarAddButtons(MainThread.MainWindow.Handle, (uint)Math.Min(_buttons.Count, 7), _buttons.ToArray()); _addedOnce = true; } else { hr = _taskbarList.ThumbBarUpdateButtons(MainThread.MainWindow.Handle, (uint)Math.Min(_buttons.Count, 7), _buttons.ToArray()); } } _buttons.Clear(); }
internal static void AddThumbnailButtons(IntPtr hwnd, params ThumbButton[] buttons) { if (IsInitialized) { HResult res = taskbar.ThumbBarAddButtons(hwnd, (uint)buttons.Length, buttons); if (res != HResult.Ok) { throw new COMException("Cannot add thumbnail button(s): " + res); } } }
// Thumbnail Toolbars ============================================ /// <summary>Adds a thumbnail toolbar with a specified set of buttons to the thumbnail image of a window in a taskbar button flyout.</summary> /// <param name="parent">The window whose thumbnail representation will receive the toolbar. This window must belong to the calling process.</param> /// <param name="buttons"> /// An array of THUMBBUTTON structures. Each THUMBBUTTON defines an individual button to be added to the toolbar. Buttons cannot be added or deleted /// later, so this must be the full defined set. Buttons also cannot be reordered, so their order in the array, which is the order in which they are /// displayed left to right, will be their permanent order. /// </param> public static void ThumbBarAddButtons(IWin32Window parent, THUMBBUTTON[] buttons) { Validate7OrLater(); if (parent == null) { throw new ArgumentNullException(nameof(parent)); } if (buttons == null) { throw new ArgumentNullException(nameof(buttons)); } taskbar4?.ThumbBarAddButtons(parent.Handle, (uint)buttons.Length, buttons); }