Sets the image list that the toolbar uses to display buttons that are in a pressed state.
The index of the image list. If you use only one image list, set this parameter to zero. See Remarks for details on using multiple image lists.
Handle to the image list to set. If this parameter is NULL, no images are displayed in the buttons.
Returns the handle to the image list previously used to display buttons in their pressed state, or NULL if no such image list was previously set.
The TB_SETPRESSEDIMAGELIST message cannot be combined with TB_ADDBITMAP. It also cannot be used with toolbars created with CreateToolbarEx, which calls TB_ADDBITMAP internally. When you create a toolbar with CreateToolbarEx or use TB_ADDBITMAP to add images, the toolbar manages the image list internally. Attempting to modify it with TB_SETPRESSEDIMAGELIST has unpredictable consequences.
Button images need not come from the same image list. To use multiple image lists for your toolbar button images:
- Enable multiple image lists by sending the toolbar control a CCM_SETVERSION message with wParam (the version number) set to 5.
- For each image list you want to use, send the toolbar control a TB_SETPRESSEDIMAGELIST message. Set wParam to an application-defined wParam value that will be used to identify the list. Set lParam to the list's HIMAGELIST handle.
- For each button, set the iBitmap member of the button's TBBUTTON structure to MAKELONG(iIndex, iImageID). The iImageID value is the ID of the appropriate image list that was defined in step two. The iIndex value is the index of the particular image within that list.
- Add the buttons by sending the toolbar control a TB_ADDBUTTONS message.
The following code fragment illustrates how to add five buttons to a toolbar, with images from three different image lists. Support for multiple image lists is enabled with a CCM_SETVERSION message. The image lists are then set and assigned IDs of 0-2. The buttons are assigned images from the image lists as follows:
- Button 0 is from image list zero (ahim) with index of 1.
- Button 1 is from image list one (ahim) with an index of 1.
- Button 2 is from image list two (ahim) with an index of 1.
- Button 3 is from image list zero (ahim) with an index of 2.
- Button 4 is from image list one (ahim) with an index of 3.
Finally, the buttons are added to the toolbar control with a TB_ADDBUTTONS message.
// Enable multiple image lists SendMessage(hwndTB, CCM_SETVERSION, (WPARAM) 5, 0); //Set the image lists and assign them IDs of 0-2 SendMessage(hwndTB, TB_SETPRESSEDIMAGELIST, 0, (LPARAM)ahiml); SendMessage(hwndTB, TB_SETPRESSEDIMAGELIST, 1, (LPARAM)ahiml); SendMessage(hwndTB, TB_SETPRESSEDIMAGELIST, 2, (LPARAM)ahiml); // Create the five buttons TBBUTTON rgtb; //... initialize the TBBUTTON structures as usual ... //Assign images to each button rgtb.iBitmap = MAKELONG(1, 0); rgtb.iBitmap = MAKELONG(1, 1); rgtb.iBitmap = MAKELONG(1, 2); rgtb.iBitmap = MAKELONG(2, 0); rgtb.iBitmap = MAKELONG(3, 1); // Add the five buttons to the toolbar control SendMessage(hwndTB, TB_ADDBUTTONS, 5, (LPARAM)(&rgtb);
Minimum supported client
|Windows Vista [desktop apps only]|
Minimum supported server
|Windows Server 2008 [desktop apps only]|