Example #1
0
		private void InitializeComponent(IContainer cont)
		{
			m_TopDockSite=null;
			m_BottomDockSite=null;
			m_LeftDockSite=null;
			m_RightDockSite=null;
			//m_MsgHandler=null;
			m_Bars=new Bars(this);
			m_WereVisible=new ArrayList();
			m_Items=new Items(this);
			m_ShortcutTable=new Hashtable();
			m_FilterInstalled=false;
			m_frmCustomize=null;
			m_DisabledControls=null;
			m_FocusItem=null;
			m_ExpandedItem=null;
			m_RegisteredPopups=new ArrayList();
			m_MdiHandler=null;
			m_ActiveMdiChild=null;
			m_IgnoreSysKeyUp=false;
			m_ImageList=null;
			m_ParentForm=null;
			m_ContextMenus=new ContextMenusCollection(this);

			if(cont!=null)
				cont.Add(this);

			if(!ColorFunctions.ColorsLoaded)
			{
				NativeFunctions.RefreshSettings();
				NativeFunctions.OnDisplayChange();
				ColorFunctions.LoadColors();
			}

			m_AutoDispatchShortcuts=new ShortcutsCollection(null);
			m_ColorScheme=new ColorScheme(m_Style);
		}
Example #2
0
		/// <summary>
		///    Clean up any resources being used.
		/// </summary>
		protected override void Dispose(bool disposing)
		{
			if(m_Disposed)
			{
				base.Dispose(disposing);
				return;
			}

			m_Disposed=true;

			if(disposing && m_License != null) 
			{
				m_License.Dispose();
				m_License = null;
			}

			if(m_ActiveMdiChild!=null)
			{
				m_ActiveMdiChild.Resize-=new EventHandler(this.OnMdiChildResize);
				m_ActiveMdiChild.VisibleChanged-=new EventHandler(this.OnMdiChildVisibleChanged);
				m_ActiveMdiChild=null;
			}

			this.Images=null;
			this.ImagesMedium=null;
			this.ImagesLarge=null;
			
			//ms_Managers.Remove(this);

			if(m_ClickTimer!=null)
			{
				m_ClickTimer.Stop();
				m_ClickTimer.Dispose();
				m_ClickTimer=null;
			}
			if(m_RegisteredPopups!=null && m_RegisteredPopups.Count>0)
			{
				BaseItem[] popups;
				lock(this)
				{
					popups=(BaseItem[])m_RegisteredPopups.ToArray(typeof(BaseItem));
				}
				foreach(PopupItem popup in popups)
					if(popup.Expanded) popup.ClosePopup();
				//m_RegisteredPopups=null;
			}

			// This was commented out becouse of the issue described below. This might have some of the same
			// problems as the solution below and after testing it did not show any ill effects.
//			if(m_MdiHandler!=null && m_MdiParentMsgHandler)
//			{
//				m_MdiHandler.ReleaseHandle();
//				m_MdiHandler=null;
//			}

			// Closing the form which contains dockable window which in turn contains the UserControl with DotNetBar and 
			// when DotNetBar is used to provide context menu for that UserControl
			// was rasing an NULL exception. fixed after 1.0.0.10
//			if(m_MsgHandler!=null)
//			{
//				m_MsgHandler.ReleaseHandle();
//				m_MsgHandler=null;
//			}
			ReleaseParentFormHooks();

			// Very bad things were happening when we put in the try..catch block, so I just commented it out. It seems it is working ok
			if(m_FilterInstalled)
			{
				// This was causing the Local Data Storage has been freed exception under some conditions. Client: [email protected], 02/25/2002
				//try
				//{
					//System.Windows.Forms.Application.RemoveMessageFilter(this);
					MessageHandler.UnregisterMessageClient(this);
				//}
				//catch(Exception)
				//{}
				m_FilterInstalled=false;
			}

			if(m_Hook!=null)
			{
				m_Hook.Dispose();
				m_Hook=null;
			}

			/*if(m_TopDockSite!=null)
			{
				if(m_TopDockSite.Parent!=null)
					m_TopDockSite.Parent.Controls.Remove(m_TopDockSite);
				m_TopDockSite.Dispose();
			}

			if(m_BottomDockSite!=null)
			{
				if(m_BottomDockSite.Parent!=null)
					m_BottomDockSite.Parent.Controls.Remove(m_BottomDockSite);
				m_BottomDockSite.Dispose();
			}

			if(m_LeftDockSite!=null)
			{
				if(m_LeftDockSite.Parent!=null)
					m_LeftDockSite.Parent.Controls.Remove(m_LeftDockSite);
				m_LeftDockSite.Dispose();
			}

			if(m_RightDockSite!=null)
			{
				if(m_RightDockSite.Parent!=null)
					m_RightDockSite.Parent.Controls.Remove(m_RightDockSite);
				m_RightDockSite.Dispose();
			}*/

			if(m_frmCustomize!=null)
			{
				m_frmCustomize.Close();
				if(m_frmCustomize!=null)
					m_frmCustomize.Dispose();
			}

			//foreach(DevComponents.DotNetBar.Bar  bar in m_Bars)
			//	bar.Dispose();
			if(m_Bars!=null)
			{
				//m_Bars.Clear();
				m_Bars=null;
			}
			if(m_Items!=null)
			{
				m_Items.Dispose();
				m_Items=null;
			}
			if(m_ContextMenus!=null)
			{
				m_ContextMenus.SetOwner(null);
				m_ContextMenus=null;
			}

			if(m_DisposeGCCollect) GC.Collect();

			base.Dispose(disposing);
		}