I cannot figure out how to develop a toolbar in Win32++ comprised of individual bitmap buttons that are defined by individual bitmap files, all of the same dimensions, say 24 x 24. I can do it using the WinApi directly, but I can't do it in Win32++. No IDW_MAIN toolbar.bmp is to be used. Any help would be appreciated. I just need to know the CFrame and/or CToolBar functions to use and in what order. I can probably figure out the rest.
My WinApi version is attached, below for reference.
Toolbars use image lists for the images displayed on Toolbar buttons. If you have a set of individual bitmaps for your toolbar buttons, you can build an image list from those and then assign it to the toolbar before adding the buttons. Toolbars can have up to 3 image list assigned, one for normal buttons, one for hot buttons and one for disabled buttons.
Steps:
- Add a CImageList member variable to CMainFrame
- Create the image list with the desired width, height (with CImageList::Create)
- Add the individual bitmaps to the image list (with CImageList.Add)
- Assign the image list to your toolbar (with CToolbar::SetImageList)
- Add the toolbar buttons.
When we add a toolbar button to the toolbar we specify the image's index. An index of 0 is the first image in the image list.
Note that we can build the image list from icons or bitmaps. Icons can be simpler to work with as we don't need to concern ourselves with bitmap masks.
Please get back to me if you need an example on how to code this.
Best regards,
David
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I cannot figure out how to develop a toolbar in Win32++ comprised of individual bitmap buttons that are defined by individual bitmap files, all of the same dimensions, say 24 x 24. I can do it using the WinApi directly, but I can't do it in Win32++. No IDW_MAIN toolbar.bmp is to be used. Any help would be appreciated. I just need to know the CFrame and/or CToolBar functions to use and in what order. I can probably figure out the rest.
My WinApi version is attached, below for reference.
/============================================================================/
void MyFrame::
CreateToolBar(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) /*
/----------------------------------------------------------------------------/
{
// Clear any error code
SetLastError(ERROR_SUCCESS);
}
Hi Robert,
Toolbars use image lists for the images displayed on Toolbar buttons. If you have a set of individual bitmaps for your toolbar buttons, you can build an image list from those and then assign it to the toolbar before adding the buttons. Toolbars can have up to 3 image list assigned, one for normal buttons, one for hot buttons and one for disabled buttons.
Steps:
- Add a CImageList member variable to CMainFrame
- Create the image list with the desired width, height (with CImageList::Create)
- Add the individual bitmaps to the image list (with CImageList.Add)
- Assign the image list to your toolbar (with CToolbar::SetImageList)
- Add the toolbar buttons.
When we add a toolbar button to the toolbar we specify the image's index. An index of 0 is the first image in the image list.
Note that we can build the image list from icons or bitmaps. Icons can be simpler to work with as we don't need to concern ourselves with bitmap masks.
Please get back to me if you need an example on how to code this.
Best regards,
David