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

  • Today's agile organizations pose operations teams with a tremendous challenge: to deploy new releases to production immediately after development and testing is completed. To ensure that applications are deployed successfully, an automatic and transparent process is required. We refer to this process as Zero Touch Deployment™. This white paper reviews two approaches to Zero Touch Deployment--a script-based solution and a release automation platform. The article discusses how each can solve the key …

  • Learn How A Global Entertainment Company Saw a 448% ROI Every business today uses software to manage systems, deliver products, and empower employees to do their jobs. But software inevitably breaks, and when it does, businesses lose money -- in the form of dissatisfied customers, missed SLAs or lost productivity. PagerDuty, an operations performance platform, solves this problem by helping operations engineers and developers more effectively manage and resolve incidents across a company's global operations. …

Most Popular Programming Stories

More for Developers

RSS Feeds