I have some class around this code, let call it ToolbarButton
TBBUTTON tbbutton;
ZeroMemory(&tbbutton, sizeof(tbbutton));
tbbutton.idCommand = index;
tbbutton.dwData = 0;
tbbutton.fsState = TBSTATE_ENABLED | BSTYLE_BUTTON | BTNS_SHOWTEXT;
tbbutton.iBitmap = I_IMAGENONE;
tbbutton.iString = toolbar->AddStrings(text);
toolbar->InsertButton(index, &tbbutton);
where toolbar is something CToolBarCtrl*
How can I create message loop for ToolbarButton class?
something like
class ToolbarButton : public CMessageMap{
..
BEGIN_MSG_MAP(ToolbarButton )
MESSAGE_HANDLER(WM_COMMAND, OnClick)
END_MSG_MAP()
..
}
OnClick didn't called, what else should I do?
Update: I also think about the variant from answer - toolbar handles click message, find button by idCommand and call OnClick of founded button. .. But I have a code that I am refactoring and see the button class (to be correct ~ about 4 interfaces and 15 classes around button) that do such syntax sugar what I need, but also they contains obsolete code and code that I want to eliminate and currently I can't slice it
It is supposed to work in a somewhat different way.
I suggest that you check Using Toolbar Controls as for what your options really are.