Ejemplo n.º 1
0
        internal static ThreadWindows DisableTaskWindows()
        {
            ThreadWindows threadWindows = new ThreadWindows();

            threadWindows.Enable(false);
            return(threadWindows);
        }
Ejemplo n.º 2
0
 internal static void EnableTaskWindows(ThreadWindows threadWindows)
 {
     threadWindows.Enable(true);
     threadWindows.Dispose();
     threadWindows = null;
 }
Ejemplo n.º 3
0
            // Disables windows in preparation of going modal.  If parameter is true, we disable all
            // windows, if false, only windows forms windows (i.e., windows controlled by this MsoComponent).
            // See also IMsoComponent.OnEnterState.
            internal void DisableWindowsForModalLoop(bool onlyWinForms, ApplicationContext context) {
                Debug.WriteLineIf(CompModSwitches.MSOComponentManager.TraceInfo, "ComponentManager : Entering modal state");
                ThreadWindows old = threadWindows;
                threadWindows = new ThreadWindows(onlyWinForms);
                threadWindows.Enable(false);
                threadWindows.previousThreadWindows = old;

                ModalApplicationContext modalContext = context as ModalApplicationContext;
                if (modalContext != null) {
                    modalContext.DisableThreadWindows(true, onlyWinForms);
                }
            }
Ejemplo n.º 4
0
		public static DialogResult ShowDialog(Form form, bool disposeForm)
		{
			DialogResult result = DialogResult.OK;

#if !NDOC && !DESIGN
			if (form == null)
			{
				throw new ArgumentNullException("form");
			}

			IntPtr lastWnd = Win32Window.GetActiveWindow();

			// it seems that Form.Close() method processes Window Queue itself that is why it is 
			// only way to be noticed the a dialog form was closed
			// If we're not supposed to dispose the form, we need to listen
			// for the closing event instead, as the form will already be disposed
			// by the time Closed is raised.
			if (disposeForm)
			{
				form.Closed += new EventHandler(ModalForm_Closed);
			}
			else
			{
				form.Closing += new System.ComponentModel.CancelEventHandler(ModalForm_Closing);					
			}

			form.Show();
			form.Capture = true;
			IntPtr hwnd = Win32Window.GetCapture();
			form.Capture = false;

			ThreadWindows previousThreadWindows = threadWindows;
			threadWindows = new ThreadWindows(hwnd);
			threadWindows.previousThreadWindows = previousThreadWindows;
			threadWindows.Enable(false);

			// enters dialog window loop
			LocalModalMessageLoop();
			
			result = form.DialogResult;
           
			if(threadWindows != null)
			{
				threadWindows = threadWindows.previousThreadWindows;
			}

			if(disposeForm)
			{
				form.Closed -= new EventHandler(ModalForm_Closed);	
				form.Dispose();
			}
			else
			{
				form.Closing -= new System.ComponentModel.CancelEventHandler(ModalForm_Closing);
			}

			if (IsWindow(lastWnd) && IsWindowVisible(lastWnd))
			{
				SetActiveWindow(lastWnd);
			}
#endif
			return result;
		}