}
return (hwndToolBar ? true : false);
};
+
+int ToolBar::addBitmap(int nButtons, UINT bitmapID) {
+ assert(nButtons > 0);
+ TBADDBITMAP resBitmap;
+ resBitmap.hInst = GetModuleHandle(0);
+ resBitmap.nID = bitmapID;
+ return SendMessage(getHandle(), TB_ADDBITMAP, nButtons, (LPARAM)&resBitmap);
+}
+
+int ToolBar::addSystemBitmap(UINT stdBitmapID) {
+ TBADDBITMAP resBitmap;
+ resBitmap.hInst = HINST_COMMCTRL;
+ resBitmap.nID = stdBitmapID;
+ return SendMessage(getHandle(), TB_ADDBITMAP, 0, (LPARAM)&resBitmap);
+}
+
+bool ToolBar::setBitmapSize(int width, int height) {
+ int result = SendMessage(getHandle(), TB_SETBITMAPSIZE,
+ 0, MAKELONG(width, height));
+ return (result ? true : false);
+}
#include <windows.h>
#include <commctrl.h>
+#include <assert.h>
class ToolBar {
public:
// or FALSE otherwise.
bool create(int tbID, HWND parentHwnd, DWORD dwStyle = WS_CHILD | WS_VISIBLE | TBSTYLE_FLAT);
+ // -=- Button images operations
+
+ // addBitmap() adds one or more images from resources to the list of button
+ // images available for a toolbar. Returns the index of the first new image
+ // if successful, or -1 otherwise.
+ int addBitmap(int nButtons, UINT bitmapID);
+
+ // addSystemBitmap() adds the system-defined button bitmaps to the list
+ // of the toolbar button specifying by stdBitmapID. Returns the index of
+ // the first new image if successful, or -1 otherwise.
+ int addSystemBitmap(UINT stdBitmapID);
+
+ // setBitmapSize() sets the size of the bitmapped images to be added
+ // to a toolbar. It returns TRUE if successful, or FALSE otherwise.
+ // You must call it before addBitmap().
+ bool setBitmapSize(int width, int height);
+
// getHandle() returns handle to a toolbar window.
HWND getHandle() { return hwndToolBar; }