Code to Dynamically Redock a Toolbar at Runtime

This is a simple code snippet that enables you to dyamically enable docking and then dock any toolbar at runtime. To use (or test) this code, simply add the following code to a COMMAND message handler such as OnChangeToolBar and the code will allow you to re-dock any undocked toolbars. Obviously, one way of implementing this would be to have a function that allows novice end-users that get happy with their mice to reset, or redock all toolbars at once. In that case, you could simply keep the toolbar ids in an array and iterate through them, redocking each one.
void CMainFrame::OnChangeToolBar() 
{
 if(!m_wndToolBar.LoadToolBar(IDR_NEWTOOLBAR))
  AfxMessageBox("Error: could not load toolbar");

 m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
 EnableDocking(CBRS_ALIGN_ANY);
 DockControlBar(&m_wndToolBar);
}


Comments

  • Docking to a specific location?

    Posted by Legacy on 09/15/2003 12:00am

    Originally posted by: Jon

    Okay, I can dock my (3) toolbars to the top of my window, but they always appear on three seperatre lines - one above the other. There must be a way to force them all onto the same line... but what is it?

    [edit]Just found the answer :) http://www.codeguru.com/toolbar/demo_toolbar_d.shtml[/edit]

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • The explosion in mobile devices and applications has generated a great deal of interest in APIs. Today's businesses are under increased pressure to make it easy to build apps, supply tools to help developers work more quickly, and deploy operational analytics so they can track users, developers, application performance, and more. Apigee Edge provides comprehensive API delivery tools and both operational and business-level analytics in an integrated platform. It is available as on-premise software or through …

  • Live Event Date: September 17, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT Another day, another end-of-support deadline. You've heard enough about the hazards of not migrating to Windows Server 2008 or 2012. What you may not know is that there's plenty in it for you and your business, like increased automation and performance, time-saving technical features, and a lower total cost of ownership. Check out this upcoming eSeminar and join Rich Holmes, Pomeroy's practice director of virtualization, as he discusses the …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds