}// Command //------------------------------------------------------- // Methods for IExtendControlbar //------------------------------------------------------- //------------------------------------------------- // SetControlbar // // This function will add items to the toolbar //------------------------------------------------- public void SetControlbar(IControlbar pControlbar) { if (pControlbar != null && false) { Object newcontrol; // Create a toolbar that we can "integrate" into the default toolbar pControlbar.Create(MMC_CONTROL_TYPE.TOOLBAR, this, out newcontrol); m_Toolbar = (IToolbar)newcontrol; // Add our bitmap to the toolbar's imagelist m_Toolbar.AddBitmap(1, m_hToolbarBMP, 16, 16, 0x00FFFFFF); // Now create the button we'll be adding to the toolbar MMCBUTTON newButton = new MMCBUTTON(); newButton.nBitmap = 0; newButton.idCommand = 1; newButton.fsState = TBSTATE.ENABLED; newButton.fsType = TBSTYLE.BUTTON; newButton.lpButtonText = "Go to the Black Page"; newButton.lpTooltipText = "This button will take you to the Black page"; m_Toolbar.AddButtons(1, ref newButton); // Now attach the toolbar we just created to MMC's toolbar pControlbar.Attach(MMC_CONTROL_TYPE.TOOLBAR, m_Toolbar); } }// SetControlbar
/// <summary> /// Called to set and reset the control bar interface. /// Implemented by Alexander Kachalkov /// </summary> public void SetControlbar(IControlbar pControlbar) { if (m_toolbar != null) { m_toolbar = null; } if (m_controlbar != null) { m_controlbar = null; } if (pControlbar == null) { return; } m_controlbar = pControlbar; object pToolBar; m_controlbar.Create(MmcControlType.Toolbar, this, out pToolBar); m_toolbar = (IToolbar)pToolBar; // Get an Hicon for the bitmap. IntPtr hBitmap = m_snapin.Images.GetBitmapHandle(m_toolbarImageIndex); if (hBitmap == IntPtr.Zero || m_toolbarButtons == null) { return; } m_toolbar.AddBitmap(m_toolbarButtons.Length, hBitmap, 16, 16, Color.Black.ToArgb()); for (int index = 0; index <= m_toolbarButtons.Length - 1; ++index) { m_toolbar.InsertButton(0, ref m_toolbarButtons[index]); } }