我正在尝试创建一个工具栏,我的位图将是40x40,我正在尝试使工具栏的宽度为40像素。我希望它是一个垂直的toobar。我只得到这段代码的横向结果:
HWND OGLTOOLBAR::create(HWND parent,HINSTANCE hInst,WNDPROC prc, int *toolWidthPtr)
{
if (toolhWnd != NULL)
{
return toolhWnd;
}
int iCBHeight; // Height of the command bar
DWORD dwStyle; // Style of the toolbar
HWND hwndTB = NULL; // Handle to the command bar control
RECT rect, // Contains the coordinates of the main
// window client area
rectTB; // Contains the dimensions of the bounding
// rectangle of the toolbar control
INITCOMMONCONTROLSEX iccex; // The INITCOMMONCONTROLSEX structure
TBBUTTON tbButton[8];
wchar_t *txt = L"wii";
for(int i = 0; i < 8; i += 2)
{
tbButton[i].iBitmap = 0;
tbButton[i].fsStyle = BTNS_BUTTON;
tbButton[i].fsState = TBSTATE_ENABLED;
tbButton[i].iString = (INT_PTR)txt;
tbButton->idCommand = 0;
}
for(int i = 1; i < 8; i += 2)
{
tbButton[i].iBitmap = 0;
tbButton[i].fsStyle = BTNS_BUTTON;
//tbButton[i].fsState = TBSTATE_ENABLED;
tbButton[i].iString = (INT_PTR)txt;\
tbButton->idCommand = 0;
}
iccex.dwSize = sizeof (INITCOMMONCONTROLSEX);
iccex.dwICC = ICC_BAR_CLASSES;
// Register toolbar control classes from the DLL for the common
// control.
InitCommonControlsEx (&iccex);
// Create the toolbar control.
dwStyle = WS_VISIBLE | WS_CHILD | TBSTYLE_TOOLTIPS | TBSTYLE_WRAPABLE | TBSTYLE_TRANSPARENT | CCS_VERT
;
if (!(hwndTB = CreateToolbarEx (
parent, // Parent window handle
dwStyle, // Toolbar window styles
(UINT) 666, // Toolbar control identifier
8, // Number of button images
hInst, // Module instance
(UINT)LoadImage(hInst,MAKEINTRESOURCE(IDB_BRUSH),0,0,0,LR_VGACOLOR), // Bitmap resource identifier
tbButton, // Array of TBBUTTON structure
// contains button data
sizeof(tbButton) / sizeof(TBBUTTON),
// Number of buttons in toolbar
40, // Width of the button in pixels
40, // Height of the button in pixels
40, // Button image width in pixels
40, // Button image height in pixels
sizeof (TBBUTTON))))// Size of a TBBUTTON structure
{
return NULL;
}
// Add ToolTips to the toolbar.
SendMessage (hwndTB, TB_SETTOOLTIPS, (WPARAM) NUM_TOOLS,
(LPARAM) 8);
// Reposition the toolbar.
GetClientRect (parent, &rect);
GetWindowRect (hwndTB, &rectTB);
iCBHeight = 40;
mainWindow = parent;
toolhWnd = hwndTB;
return hwndTB;
}
我确信CCS_VERT应该让它垂直。我怎样才能使这个托巴尔宽约40像素,并且有8个方格向下而不是水平。感谢
我真的不想要分隔符,我只是觉得这会有所帮助,但它没有......