June 6th, 2011, 11:32 PM
Wrapping toolbar problem
I've set up a Toolbar control with the TBSTYLE_WRAPABLE style. On the parent window's WM_SIZE, I send TB_AUTOSIZE to the toolbar to get it to adjust its size accordingly. I then get the height of the tool bar to calculate the top edge of other child controls.
When the parent window is wide enough to fit all toolbar buttons on a single row, it works perfectly. The problem is, if I make the parent window smaller, causing the buttons to wrap on additional rows, the height of the toolbar becomes far larger than it needs to be.
I sent TB_GETROWS to the control after sending TB_AUTOSIZE to find out what is going on. I've found that it returns 3 rows when it should be 2, 5 rows when it should be 3, and so on.
It appears that the control is incorrectly calculating the number of rows required to show all buttons.
Is this normal behavior? MSDN says nothing about this, and I haven't been able to find any other programs that use wrapping toolbars, so I can't verify if it is just my code or if the problem is with the common controls library.
Perhaps I should do more than just send TB_AUTOSIZE to update the toolbar?
Click Here to Expand Forum to Full Width
This is a CodeGuru survey question.