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

  • "Security" is the number one issue holding business leaders back from the cloud. But does the reality match the perception? Keeping data close to home, on premises, makes business and IT leaders feel inherently more secure. But the truth is, cloud solutions can offer companies real, tangible security advantages. Before you assume that on-site is the only way to keep data safe, it's worth taking a comprehensive approach to evaluating risks. Doing so can lead to big benefits.

  • Hybrid cloud platforms need to think in terms of sweet spots when it comes to application platform interface (API) integration. Cloud Velocity has taken a unique approach to tight integration with the API sweet spot; enough to support the agility of physical and virtual apps, including multi-tier environments and databases, while reducing capital and operating costs. Read this case study to learn how a global-level Fortune 1000 company was able to deploy an entire 6+ TB Oracle eCommerce stack in Amazon Web …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds