Board index » Visual Studio » dynamic toolbars

dynamic toolbars

Visual Studio365
Hi,



I made one application which initially has only onr button on the

toolbar. When you click on that button the function is called having

the code..



m_wndToolBar.SetButtons(NULL, 3);

m_wndToolBar.SetButtonInfo(0, ID_APP_ABOUT, TBBS_BUTTON, 7);

m_wndToolBar.SetButtonInfo(1, ID_FILE_NEW, TBBS_BUTTON, 0);

m_wndToolBar.SetButtonInfo(2, ID_EDIT_CUT, TBBS_BUTTON, 3);



m_wndToolBar.Invalidate();



But still i can see only on button on the toolbar. when i resize the

window then i got to see the toolbar with 3 bottons.

what is the reason?



I am able to solve the problem by adding one line at the end of above

mention code



m_wndToolBar.SetButtons(NULL, 3);

m_wndToolBar.SetButtonInfo(0, ID_APP_ABOUT, TBBS_BUTTON, 7);

m_wndToolBar.SetButtonInfo(1, ID_FILE_NEW, TBBS_BUTTON, 0);

m_wndToolBar.SetButtonInfo(2, ID_EDIT_CUT, TBBS_BUTTON, 3);



m_wndToolBar.Invalidate();



SendMessage(WM_SIZE); // <-----------



is this the best way ?



what is the best way to create dynamic toolbars.



thanks

dev


-
 

Re:dynamic toolbars

Call RecalcLayout of the frame window. Or if you don't have access to the

frame window, or the toolbar doesn't belong to a frame you can call

CWnd::RepostionBars directly.



AliR.



"dev" <dev.core.mfc@gmail.com>wrote in message

Quote
Hi,



I made one application which initially has only onr button on the

toolbar. When you click on that button the function is called having

the code..



m_wndToolBar.SetButtons(NULL, 3);

m_wndToolBar.SetButtonInfo(0, ID_APP_ABOUT, TBBS_BUTTON, 7);

m_wndToolBar.SetButtonInfo(1, ID_FILE_NEW, TBBS_BUTTON, 0);

m_wndToolBar.SetButtonInfo(2, ID_EDIT_CUT, TBBS_BUTTON, 3);



m_wndToolBar.Invalidate();



But still i can see only on button on the toolbar. when i resize the

window then i got to see the toolbar with 3 bottons.

what is the reason?



I am able to solve the problem by adding one line at the end of above

mention code



m_wndToolBar.SetButtons(NULL, 3);

m_wndToolBar.SetButtonInfo(0, ID_APP_ABOUT, TBBS_BUTTON, 7);

m_wndToolBar.SetButtonInfo(1, ID_FILE_NEW, TBBS_BUTTON, 0);

m_wndToolBar.SetButtonInfo(2, ID_EDIT_CUT, TBBS_BUTTON, 3);



m_wndToolBar.Invalidate();



SendMessage(WM_SIZE); // <-----------



is this the best way ?



what is the best way to create dynamic toolbars.



thanks

dev







-