Code: Select all
void APIWrap::CToolbarCtrl::AddButton(int nIndex, int nCommandID,
APIWrap::CBitmap& bmpButtonImage)
{
this->AddBitmap(bmpButtonImage.GetHBITMAP());
TBBUTTON tbb;
ZeroMemory(&tbb, sizeof(tbb));
tbb.iBitmap = m_pmapBitmaps->GetItem(bmpButtonImage.GetHBITMAP());
tbb.idCommand = nCommandID;
tbb.fsState = TBSTATE_ENABLED;
tbb.fsStyle = TBSTYLE_BUTTON;
this->InsertButton(nIndex, tbb);
}
void APIWrap::CToolbarCtrl::AddButton(int nIndex, int nCommandID,
APIWrap::CBitmap& bmpButtonImage,
const APIWrap::CString& strButtonText)
{
this->AddBitmap(bmpButtonImage.GetHBITMAP());
this->AddString(strButtonText);
TBBUTTON tbb;
ZeroMemory(&tbb, sizeof(tbb));
tbb.iBitmap = m_pmapBitmaps->GetItem(bmpButtonImage.GetHBITMAP());
tbb.idCommand = nCommandID;
tbb.fsState = TBSTATE_ENABLED;
tbb.fsStyle = TBSTYLE_BUTTON;
tbb.iString = m_pmapStrings->GetItem(strButtonText);
this->InsertButton(nIndex, tbb);
}
This problem applies specifically to mixing the string and non-string versions, because it works fine if they are not mixed. I tried setting the iString member of the TBBUTTON structure to -1 in the non-string AddButton and it seems to work. What I want to know is if that is legal as a way to specify "no string for this button" or if it can cause problems. Anybody know?