Sizing Toolbar buttons (Win32)
-
Hi, My problem is that I can't make the size of the toolbar buttons right. This is my code:
HWND CreateMyToolbar(HWND hWnd) { HWND hToolbar; hToolbar = NULL; hToolbar = CreateWindowEx(0,TOOLBARCLASSNAME,"MyToolbar",WS_CHILD|WS_VISIBLE|TBSTYLE_TOOLTIPS ,0,0,0,0,hWnd,0,g_hInstance,NULL); if(hToolbar) { SendMessage(hToolbar, TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0); TBBUTTON tbb[1]; TBADDBITMAP tbab; tbab.hInst = HINST_COMMCTRL; tbab.nID = IDB_STD_LARGE_COLOR; SendMessage(hToolbar, TB_ADDBITMAP, 0, (LPARAM)&tbab); ZeroMemory(tbb, sizeof(tbb)); tbb[0].iBitmap = STD_FILENEW; tbb[0].fsState = TBSTATE_ENABLED; tbb[0].fsStyle = TBSTYLE_BUTTON; tbb[0].idCommand = IDM_FILENEW; SendMessage(hToolbar, TB_ADDBUTTONS, sizeof(tbb)/sizeof(TBBUTTON), (LPARAM)&tbb); return hToolbar; } return NULL; }
I've set the IDB_STD_LARGE_COLOR imagelist, but in the result the button image is clipped on the bottom. Can someone show me how to do this right? thanks in advance, Ward -
Hi, My problem is that I can't make the size of the toolbar buttons right. This is my code:
HWND CreateMyToolbar(HWND hWnd) { HWND hToolbar; hToolbar = NULL; hToolbar = CreateWindowEx(0,TOOLBARCLASSNAME,"MyToolbar",WS_CHILD|WS_VISIBLE|TBSTYLE_TOOLTIPS ,0,0,0,0,hWnd,0,g_hInstance,NULL); if(hToolbar) { SendMessage(hToolbar, TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0); TBBUTTON tbb[1]; TBADDBITMAP tbab; tbab.hInst = HINST_COMMCTRL; tbab.nID = IDB_STD_LARGE_COLOR; SendMessage(hToolbar, TB_ADDBITMAP, 0, (LPARAM)&tbab); ZeroMemory(tbb, sizeof(tbb)); tbb[0].iBitmap = STD_FILENEW; tbb[0].fsState = TBSTATE_ENABLED; tbb[0].fsStyle = TBSTYLE_BUTTON; tbb[0].idCommand = IDM_FILENEW; SendMessage(hToolbar, TB_ADDBUTTONS, sizeof(tbb)/sizeof(TBBUTTON), (LPARAM)&tbb); return hToolbar; } return NULL; }
I've set the IDB_STD_LARGE_COLOR imagelist, but in the result the button image is clipped on the bottom. Can someone show me how to do this right? thanks in advance, Ward