tags:

views:

37

answers:

1

I'm trying to create a toolbar where my bitmaps will be 40x40 and I'm trying to make the toolbar 40 pixels in width. I want it to be a vertical toobar. I'm getting nothing but horizontal results from this code:

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;

}

I was sure that CCS_VERT was supposed to make it vertical. How can I make this toobar ~40 pixels wide and have 8 squares going downward instead of horizontal. Thanks

I don't really want separators, I just thought this would help but it didn't...

A: 

From the SDK docs:

Creating a Vertical Toolbar

The key to creating a vertical toolbar is to include CCS_VERT in the window style, and to set the TBSTATE_WRAP style for each button

Emphasis added.

Hans Passant