Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
You can assign text to an existing button by using the TB_SETBUTTONINFO message.
What you need to know
Technologies
Prerequisites
- C/C++
- Windows User Interface Programming
Instructions
Dynamically Label a Toolbar Button
The following example demonstrates how to change the text of the third button in the previous examples from Save to Save As.
LRESULT RelabelButton(HWND hWndToolbar)
{
TBBUTTONINFO tbInfo;
tbInfo.cbSize = sizeof(TBBUTTONINFO);
tbInfo.dwMask = TBIF_TEXT;
tbInfo.pszText = L"Save As";
return SendMessage(hWndToolbar, TB_SETBUTTONINFO, (WPARAM)IDM_SAVE, (LPARAM)&tbInfo);
}
Remarks
Changing a button's text by using TB_SETBUTTONINFO does not affect the string that is assigned to that button in the internal string list.
If you add a toolbar button string to the internal text list, you cannot retrieve the index of that string by calling TBN_GETBUTTONINFO—you must use the TB_GETBUTTON message instead.
Related topics