ITaskbarList3::ThumbBarUpdateButtons 方法(shobjidl_core.h)

根据窗口的当前状态,显示、启用、禁用或隐藏缩略图工具栏中的按钮。 缩略图工具栏是嵌入任务栏按钮浮出控件中窗口缩略图中的工具栏。

Syntax

HRESULT ThumbBarUpdateButtons(
  [in] HWND          hwnd,
  [in] UINT          cButtons,
  [in] LPTHUMBBUTTON pButton
);

参数

[in] hwnd

类型:HWND

其缩略图表示形式包含工具栏的窗口的句柄。

[in] cButtons

类型: UINT

pButton 指向的数组中定义的按钮数。 允许的最大按钮数为 7。 此数组仅包含表示正在更新的现有按钮的结构。

[in] pButton

类型: LPTHUMBBUTTON

指向 THUMBBUTTON 结构的数组的指针。 每个 THUMBBUTTON 定义单个按钮。 如果该按钮已存在(已定义 iId 值),则使用结构中提供的信息更新现有按钮。

返回值

类型:HRESULT

如果此方法成功,则返回 S_OK。 否则,它将返回 HRESULT 错误代码。

注解

由于显示缩略图的空间有限,以及要显示的缩略图数量不断变化,因此应用程序不能保证特定的工具栏大小。 如果显示空间较低,工具栏中的按钮会根据需要从右到左截断。 因此,应用程序应确定与其按钮关联的命令的优先级,以确保优先级最高的命令位于左侧,因此不太可能被截断。

只有在任务栏上显示缩略图时,才会显示缩略图工具栏。 例如,如果任务栏按钮表示一个窗口比显示缩略图空间更大的组,UI 将还原为旧菜单而不是缩略图。

Accessibility

有关拇指栏按钮图像中的辅助功能的信息,请参阅 ThumbBarSetImageList 的“备注”部分。

例子

以下示例演示如何使用 ThumbBarUpdateButtons 更改扩展任务栏上缩略图工具栏中现有按钮上的文本和图像。

HRESULT UpdateThumbBarButton(HWND hwnd)
{
    // Define a single structure for the button to update. The ID is that
    // of an existing button, so the other information (bitmap index and 
    // tooltip) overwrites the existing values, updating the button.
    THUMBBUTTON thbButton;
    thbButton.dwMask = THB_BITMAP | THB_TOOLTIP;
    thbButtons[0].iId = 1;
    thbButton.iBitmap = 3;
    thbButton.pszTip = TEXT("Different Text");
    
    // Create an instance of ITaskbarList3
    ITaskBarList3 *ptbl;
    HRESULT hr = CoCreateInstance(CLSID_TaskbarList, 
                                  NULL, 
                                  CLSCTX_INPROC_SERVER, 
                                  IID_PPV_ARGS(&ptbl);

    if (SUCCEEDED(hr))
    {
        // Update the toolbar. In this case, only the single button is updated.
        hr = ptbl->ThumbBarUpdateButtons(hwnd, 1, &thbButton);
        ptbl->Release();
    }
    return hr;
}

要求

Requirement 价值
最低支持的客户端 Windows 7 [仅限桌面应用]
支持的最低服务器 Windows Server 2008 R2 [仅限桌面应用]
目标平台 Windows操作系统
Header shobjidl_core.h (包括 Shobjidl.h)
Library Explorerframe.lib
DLL Explorerframe.dll

另请参阅

ITaskbarList

ITaskbarList2

ITaskbarList3

ITaskbarList3::ThumbBarSetImageList

ITaskbarList3::ThumbBarAddButtons

任务栏扩展