I created a toolbar with the following styles:
DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS
| CCS_NODIVIDER | CCS_NOPARENTALIGN | CCS_NORESIZE
| TBSTYLE_FLAT | TBSTYLE_LIST;
Then I fill the toolbar with text-only buttons:
bool InsertButton(int Index, int CmdId, BYTE Style, BYTE State,
int TxtIdx, DWORD_PTR lParam)
{
TBBUTTON tbb = { 0 };
tbb.idCommand = CmdId;
tbb.fsStyle = Style; // == BTNS_AUTOSIZE | BTNS_DROPDOWN
tbb.fsState = State;
tbb.iBitmap = I_IMAGENONE;
tbb.iString = TxtIdx;
tbb.dwData = lParam;
return (bool)CToolBarCtrl::InsertButton(Index, &tbb);
}
After the toolbar is filled up, I want to get the actual size of its buttons. But the GetButtonInfo returns zero size.
int GetBtnSize(int Idx) const
{
TBBUTTONINFO tbbi = { sizeof(tbbi), TBIF_SIZE | TBIF_BYINDEX };
GetButtonInfo(Idx, &tbbi);
return tbbi.cx;
}
What am I doing wrong and how can I know the button's actual size?