共用方式為


ITaskbarList3::ThumbBarUpdateButtons 方法 (shobjidl_core.h)

根據視窗目前狀態的要求,在縮圖工具列中顯示、啟用、停用或隱藏按鈕。 縮圖工具列是內嵌在工作列按鈕飛出視窗中視窗縮圖影像中的工具列。

語法

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 會還原為舊版功能表,而不是縮圖。

可及性

如需拇指列按鈕影像中協助工具的相關資訊,請參閱 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 [僅限傳統型應用程式]
目標平臺 窗戶
Header shobjidl_core.h(包括 Shobjidl.h)
Library 瀏覽器框架.lib
DLL Explorerframe.dll

另請參閱

ITaskbar清單

IT問欄清單2

ITaskbar清單3

ITaskbarList3::ThumbBarSetImageList

ITaskbarList3::ThumbBarAddButtons

工作列延伸模組