AddOwnedForm() public method

public AddOwnedForm ( Form ownedForm ) : void
ownedForm Form
return void
示例#1
0
		public ToolArgsDialog(LogTabWindow logTabWin, Form parent)
		{
			this.logTabWin = logTabWin;
			parent.AddOwnedForm(this);
			this.TopMost = parent.TopMost;
			InitializeComponent();
		}
        public static void Show(Form newForm, Document targetDocument = null, Form parentForm = null)
        {
            AddKeyEvents(newForm);
            if (parentForm == null)
            {
                newForm.StartPosition = FormStartPosition.CenterScreen;
            }
            else
            {
                parentForm.AddOwnedForm(newForm);
                newForm.StartPosition = FormStartPosition.Manual;
                newForm.Location      = new Point(parentForm.Location.X + (parentForm.Width - newForm.Width) / 2, parentForm.Location.Y + (parentForm.Height - newForm.Height) / 2);
            }

            if (targetDocument != null && newForm is IHaveCollector formWithCollector)
            {
                formWithCollector.SetDocument(targetDocument);
            }
            newForm.Show(new ModelessWindowHandle(parentForm));
            newForm.FormClosed += (s, e) =>
            {
                ModelessWindowHandle.BringRevitToFront();
                FocusOwner((Form)s);
            };
        }
        public static SupportingFilesForm ShowForm(Form parent, BlogPostEditingManager editingManager)
        {
            SupportingFilesForm supportingFilesForm = new SupportingFilesForm();
            parent.AddOwnedForm(supportingFilesForm);
            supportingFilesForm.Show();
            Point location = parent.Location;
            Size size = parent.Size;
            supportingFilesForm.Location = new Point(location.X + size.Width + 2, location.Y);

            supportingFilesForm.BlogPostEditingManager = editingManager;
            return supportingFilesForm;
        }
示例#4
0
        /// <summary>
        /// Shows the specified Form as a popup window, keeping the
        /// Owner's title bar active and preparing to cancel the popup
        /// should the user click anywhere outside the popup window.
        /// <para>Typical code to use this message is as follows:</para><code>
        /// frmPopup popup = new frmPopup();
        /// Point location = this.PointToScreen(new Point(button1.Left, button1.Bottom));
        /// popupHelper.ShowPopup(this, popup, location);
        /// </code><para>Put as much initialisation code as possible
        /// into the popup form's constructor, rather than the <see cref="System.Windows.Forms.Load" />
        /// event as this will improve visual appearance.</para>
        /// </summary>
        /// <param name="owner">Main form which owns the popup</param>
        /// <param name="popup">Window to show as a popup</param>
        /// <param name="location">Location relative to the screen to show the popup at.</param>
        public void ShowPopup(System.Windows.Forms.Form owner, System.Windows.Forms.Form popup, Point location)
        {
            this.owner = owner;
            this.popup = popup;

            // Start checking for the popup being cancelled
            Application.AddMessageFilter(filter);

            // Set the location of the popup form:
            popup.StartPosition = FormStartPosition.Manual;
            popup.Location      = location;
            // Make it owned by the window that's displaying it:
            owner.AddOwnedForm(popup);
            // Respond to the Closed event in case the popup
            // is closed by its own internal means
            popClosedHandler = new EventHandler(popup_Closed);
            popup.Closed    += popClosedHandler;

            // Show the popup:
            this.popupShowing = true;
            popup.Show();
            popup.Activate();

            // A little bit of fun.  We've shown the popup,
            // but because we've kept the main window's
            // title bar in focus the tab sequence isn't quite
            // right.  This can be fixed by sending a tab,
            // but that on its own would shift focus to the
            // second control in the form.  So send a tab,
            // followed by a reverse-tab.

            // Send a Tab command:
            NativeMethods.keybd_event((byte)Keys.Tab, 0, 0, 0);
            NativeMethods.keybd_event((byte)Keys.Tab, 0, NativeMethods.KEYEVENTF_KEYUP, 0);

            // Send a reverse Tab command:
            NativeMethods.keybd_event((byte)Keys.ShiftKey, 0, 0, 0);
            NativeMethods.keybd_event((byte)Keys.Tab, 0, 0, 0);
            NativeMethods.keybd_event((byte)Keys.Tab, 0, NativeMethods.KEYEVENTF_KEYUP, 0);
            NativeMethods.keybd_event((byte)Keys.ShiftKey, 0, NativeMethods.KEYEVENTF_KEYUP, 0);


            // Start filtering for mouse clicks outside the popup
            filter.Popup = popup;
        }
        /// <summary>
        /// Shows the specified Form as a popup window, keeping the
        /// Owner's title bar active and preparing to cancel the popup
        /// should the user click anywhere outside the popup window.
        /// <para>Typical code to use this message is as follows:</para>
        /// <code>
        ///    frmPopup popup = new frmPopup();
        ///    Point location = this.PointToScreen(new Point(button1.Left, button1.Bottom));
        ///    popupHelper.ShowPopup(this, popup, location);
        /// </code>
        /// <para>Put as much initialisation code as possible
        /// into the popup form's constructor, rather than the <see cref="System.Windows.Forms.Load"/>
        /// event as this will improve visual appearance.</para>
        /// </summary>
        /// <param name="Owner">Main form which owns the popup</param>
        /// <param name="Popup">Window to show as a popup</param>
        /// <param name="v">Location relative to the screen to show the popup at.</param>
        public void ShowDropDown(Form Owner, Form DropDown, Point Location)
        {
            _owner = Owner;
            _dropDown = DropDown;
            Application.AddMessageFilter(_filter);					// Start checking for the popup being cancelled
            DropDown.StartPosition = FormStartPosition.Manual;		// Set the location of the popup form:
            DropDown.Location = Location;
            Owner.AddOwnedForm(DropDown);							// Make it owned by the window that's displaying it:
            DropDownClosedHandler = new EventHandler(Popup_Closed);	// Respond to the Closed event in case the popup is closed by its own internal means
            DropDown.Closed += DropDownClosedHandler;

            _dropDownShowing = true;								// Show the popup:
            DropDown.Show();
            DropDown.Activate();

            // A little bit of fun.  We've shown the popup, but because we've kept the main window's
            // title bar in focus the tab sequence isn't quite right.  This can be fixed by sending a tab,
            // but that on its own would shift focus to the second control in the form.  So send a tab,
            // followed by a reverse-tab.
            UIApiCalls.keybd_event((byte) Keys.Tab, 0, 0, 0);
            UIApiCalls.keybd_event((byte) Keys.Tab, 0, UIApiCalls.KEYEVENTF_KEYUP, 0);
            UIApiCalls.keybd_event((byte) Keys.ShiftKey, 0, 0, 0);
            UIApiCalls.keybd_event((byte) Keys.Tab, 0, 0, 0);
            UIApiCalls.keybd_event((byte) Keys.Tab, 0, UIApiCalls.KEYEVENTF_KEYUP, 0);
            UIApiCalls.keybd_event((byte) Keys.ShiftKey, 0, UIApiCalls.KEYEVENTF_KEYUP, 0);

            _filter.DropDown = DropDown;							// Start filtering for mouse clicks outside the popup
        }
示例#6
0
		public void TestPublicMethods ()
		{
			// Public Methods that force Handle creation:
			// - CreateGraphics ()
			// - GetChildAtPoint ()
			// - Invoke, BeginInvoke throws InvalidOperationException if Handle has not been created
			// - PointToClient ()
			// - PointToScreen ()
			// - RectangleToClient ()
			// - RectangleToScreen ()
			// - Select ()
			// - Show (IWin32Window)
			// Notes:
			// - CreateControl does NOT force Handle creation!
			
			Form c = new Form ();

			c.BringToFront ();
			Assert.IsFalse (c.IsHandleCreated, "A1");
			
			c.Contains (new Form ());
			Assert.IsFalse (c.IsHandleCreated, "A2");
			
			c.CreateControl ();
			Assert.IsFalse (c.IsHandleCreated, "A3");
			
			c = new Form ();
			Graphics g = c.CreateGraphics ();
			g.Dispose ();
			Assert.IsTrue (c.IsHandleCreated, "A4");
			c.Dispose ();
			c = new Form ();
			
			c.Dispose ();
			Assert.IsFalse (c.IsHandleCreated, "A5");
			c = new Form ();

			// This is weird, it causes a form to appear that won't go away until you move the mouse over it, 
			// but it doesn't create a handle??
			//DragDropEffects d = c.DoDragDrop ("yo", DragDropEffects.None);
			//Assert.IsFalse (c.IsHandleCreated, "A6");
			//Assert.AreEqual (DragDropEffects.None, d, "A6b");
			
			//Bitmap b = new Bitmap (100, 100);
			//c.DrawToBitmap (b, new Rectangle (0, 0, 100, 100));
			//Assert.IsFalse (c.IsHandleCreated, "A7");
			//b.Dispose ();
			c.FindForm ();
			Assert.IsFalse (c.IsHandleCreated, "A8");
			
			c.Focus ();
			Assert.IsFalse (c.IsHandleCreated, "A9");

			c.GetChildAtPoint (new Point (10, 10));
			Assert.IsTrue (c.IsHandleCreated, "A10");
			c.Dispose ();
			c = new Form ();
			
			c.GetContainerControl ();
			Assert.IsFalse (c.IsHandleCreated, "A11");
			c.Dispose ();
			
			c = new Form ();
			c.GetNextControl (new Control (), true);
			Assert.IsFalse (c.IsHandleCreated, "A12");
			c.GetPreferredSize (Size.Empty);
			Assert.IsFalse (c.IsHandleCreated, "A13");
			c.Hide ();
			Assert.IsFalse (c.IsHandleCreated, "A14");
			
			c.Invalidate ();
			Assert.IsFalse (c.IsHandleCreated, "A15");
			
			//c.Invoke (new InvokeDelegate (InvokeMethod));
			//Assert.IsFalse (c.IsHandleCreated, "A16");
			c.PerformLayout ();
			Assert.IsFalse (c.IsHandleCreated, "A17");
			
			c.PointToClient (new Point (100, 100));
			Assert.IsTrue (c.IsHandleCreated, "A18");
			c.Dispose ();
			c = new Form ();
			
			c.PointToScreen (new Point (100, 100));
			Assert.IsTrue (c.IsHandleCreated, "A19");
			c.Dispose ();
			
			c = new Form ();
			
			//c.PreProcessControlMessage   ???
			//c.PreProcessMessage          ???
			c.RectangleToClient (new Rectangle (0, 0, 100, 100));
			Assert.IsTrue (c.IsHandleCreated, "A20");
			c.Dispose ();
			c = new Form ();
			c.RectangleToScreen (new Rectangle (0, 0, 100, 100));
			Assert.IsTrue (c.IsHandleCreated, "A21");
			c.Dispose ();
			c = new Form ();
			c.Refresh ();
			Assert.IsFalse (c.IsHandleCreated, "A22");
			c.ResetBackColor ();
			Assert.IsFalse (c.IsHandleCreated, "A23");
			c.ResetBindings ();
			Assert.IsFalse (c.IsHandleCreated, "A24");
			c.ResetCursor ();
			Assert.IsFalse (c.IsHandleCreated, "A25");
			c.ResetFont ();
			Assert.IsFalse (c.IsHandleCreated, "A26");
			c.ResetForeColor ();
			Assert.IsFalse (c.IsHandleCreated, "A27");
			c.ResetImeMode ();
			Assert.IsFalse (c.IsHandleCreated, "A28");
			c.ResetRightToLeft ();
			Assert.IsFalse (c.IsHandleCreated, "A29");
			c.ResetText ();
			Assert.IsFalse (c.IsHandleCreated, "A30");
			c.SuspendLayout ();
			Assert.IsFalse (c.IsHandleCreated, "A31");
			c.ResumeLayout ();
			Assert.IsFalse (c.IsHandleCreated, "A32");
			c.Scale (new SizeF (1.5f, 1.5f));
			Assert.IsFalse (c.IsHandleCreated, "A33");
			c.Select ();
			Assert.IsTrue (c.IsHandleCreated, "A34");
			c.Dispose ();
			
			c = new Form ();
			
			c.SelectNextControl (new Control (), true, true, true, true);
			Assert.IsFalse (c.IsHandleCreated, "A35");
			c.SetBounds (0, 0, 100, 100);
			Assert.IsFalse (c.IsHandleCreated, "A36");
			c.Update ();
			Assert.IsFalse (c.IsHandleCreated, "A37");
			
			// Form
			
			c.Activate ();
			Assert.IsFalse (c.IsHandleCreated, "F1");
			
			c.AddOwnedForm (new Form ());
			Assert.IsFalse (c.IsHandleCreated, "F2");
			
			c.Close ();
			Assert.IsFalse (c.IsHandleCreated, "F3");
			
			c.Hide ();
			Assert.IsFalse (c.IsHandleCreated, "F4");
			
			c.LayoutMdi (MdiLayout.Cascade);
			Assert.IsFalse (c.IsHandleCreated, "F5");

#if !MONO
			c.PerformAutoScale ();
			Assert.IsFalse (c.IsHandleCreated, "F6"); 
#endif
			
			c.PerformLayout ();
			Assert.IsFalse (c.IsHandleCreated, "F7");
			
			c.AddOwnedForm (new Form ());
			c.RemoveOwnedForm (c.OwnedForms [c.OwnedForms.Length - 1]);
			Assert.IsFalse (c.IsHandleCreated, "F8");
			
			c.ScrollControlIntoView (null);
			Assert.IsFalse (c.IsHandleCreated, "F9");
			
			c.SetAutoScrollMargin (7, 13);
			Assert.IsFalse (c.IsHandleCreated, "F10");
			
			c.SetDesktopBounds (-1, -1, 144, 169);
			Assert.IsFalse (c.IsHandleCreated, "F11");
			
			c.SetDesktopLocation (7, 13);
			Assert.IsFalse (c.IsHandleCreated, "F12");

			c = new Form ();
			c.Show (null);
			Assert.IsTrue (c.IsHandleCreated, "F13");
			c.Close ();
			c = new Form (); 
			
			//c.ShowDialog ()
			
			c.ToString ();
			Assert.IsFalse (c.IsHandleCreated, "F14");
			
			c.Validate ();
			Assert.IsFalse (c.IsHandleCreated, "F15");

#if !MONO
			c.ValidateChildren ();
			Assert.IsFalse (c.IsHandleCreated, "F16"); 
#endif

			c.Close ();
		}
      /// <summary>
      /// Shows the specified Form as a popup window, keeping the
      /// Owner's title bar active and preparing to cancel the popup
      /// should the user click anywhere outside the popup window.
      /// <para>Typical code to use this message is as follows:</para>
      /// <code>
      ///    frmPopup popup = new frmPopup();
      ///    Point location = this.PointToScreen(new Point(button1.Left, button1.Bottom));
      ///    popupHelper.ShowPopup(this, popup, location);
      /// </code>
      /// <para>Put as much initialisation code as possible
      /// into the popup form's constructor, rather than the <see cref="System.Windows.Forms.Load"/>
      /// event as this will improve visual appearance.</para>
      /// </summary>
      /// <param name="owner">Main form which owns the popup</param>
      /// <param name="popup">Window to show as a popup</param>
      /// <param name="location">Location relative to the screen to show the popup at.</param>
      public void ShowPopup(Form owner, Form popup, Point location)
      {

         this.owner = owner;
         this.popup = popup;

         // Start checking for the popup being cancelled
         Application.AddMessageFilter(filter);

         // Set the location of the popup form:
         popup.StartPosition = FormStartPosition.Manual;
         popup.Location = location;
         // Make it owned by the window that's displaying it:
         owner.AddOwnedForm(popup);
         // Respond to the Closed event in case the popup
         // is closed by its own internal means
         popClosedHandler = new EventHandler(popup_Closed);
         popup.Closed += popClosedHandler;

         // Show the popup:
         this.popupShowing = true;
         popup.Show();
         popup.Activate();

         // A little bit of fun.  We've shown the popup,
         // but because we've kept the main window's
         // title bar in focus the tab sequence isn't quite
         // right.  This can be fixed by sending a tab,
         // but that on its own would shift focus to the
         // second control in the form.  So send a tab,
         // followed by a reverse-tab.

         // Send a Tab command:
         NativeMethods.keybd_event((byte)Keys.Tab, 0, 0, 0);
         NativeMethods.keybd_event((byte)Keys.Tab, 0, NativeMethods.KEYEVENTF_KEYUP, 0);

         // Send a reverse Tab command:
         NativeMethods.keybd_event((byte)Keys.ShiftKey, 0, 0, 0);
         NativeMethods.keybd_event((byte)Keys.Tab, 0, 0, 0);
         NativeMethods.keybd_event((byte)Keys.Tab, 0, NativeMethods.KEYEVENTF_KEYUP, 0);
         NativeMethods.keybd_event((byte)Keys.ShiftKey, 0, NativeMethods.KEYEVENTF_KEYUP, 0);


         // Start filtering for mouse clicks outside the popup
         filter.Popup = popup;

      }
示例#8
0
        /// <summary>
        /// Called after the calculation of the report has been finished.
        /// </summary>
        /// <param name="Calculator"></param>
        /// <param name="ACallerForm"></param>
        /// <param name="AReportName"></param>
        /// <param name="AWrapColumn"></param>
        public static void PreviewReport(TRptCalculator Calculator, Form ACallerForm, String AReportName, bool AWrapColumn)
        {
            // Create a print window with all kinds of output options
            TFrmPrintPreview printWindow = new TFrmPrintPreview(ACallerForm, AReportName, Calculator.GetDuration(),
                Calculator.GetResults(), Calculator.GetParameters(), AWrapColumn, Calculator);

            ACallerForm.AddOwnedForm(printWindow);
            printWindow.Owner = ACallerForm;

// TODO     printWindow.SetPrintChartProcedure(GenerateChart);
            printWindow.ShowDialog();
        }
		/// <summary>
		/// 
		/// </summary>
		/// <param name="parameters"></param>
		public StereoDualHeadDisplay( Game game, GraphicsDevice device, GraphicsParameters parameters ) : base( game, device, parameters )
		{
			try {
				NvApi.Initialize();
				NvApi.Stereo_Disable();
			}
			catch (NVException nvex) {
				Log.Debug(nvex.Message);
			}

			var featureLevel	=	HardwareProfileChecker.GetFeatureLevel( parameters.GraphicsProfile ); 

			Adapter	adapter;
			Output leftOut, rightOut;

			GetDualHeadAdapter( featureLevel, out adapter, out leftOut, out rightOut );
			


			window1	=	CreateForm( parameters, leftOut );
			window2	=	CreateForm( parameters, rightOut );
			window1.Tag	=	leftOut.Description;
			window2.Tag	=	rightOut.Description;

			window1.AddOwnedForm( window2 );

			window2.Show();
			window1.Show();

			window1.Resize += window_Resize;
			window2.Resize += window_Resize;
			window1.Move += window_Move;	
			window2.Move += window_Move;
			window1.Activated += window_Activated;
			window2.Activated += window_Activated;
			targetForm	=	window1;



			var deviceFlags			=	DeviceCreationFlags.None;
				deviceFlags			|=	parameters.UseDebugDevice ? DeviceCreationFlags.Debug : DeviceCreationFlags.None;


			swapChainDesc1 = new SwapChainDescription () {
				BufferCount			=	1,
				ModeDescription		=	new ModeDescription( parameters.Width, parameters.Height, new Rational(60, 1), Format.R8G8B8A8_UNorm ),
				IsWindowed			=	true,
				OutputHandle		=	window1.Handle,
				SampleDescription	=	new SampleDescription(parameters.MsaaLevel, 0),
				SwapEffect			=	SwapEffect.Discard,
				Usage				=	Usage.RenderTargetOutput,
				Flags				=	SwapChainFlags.None,
			};

			swapChainDesc2 = new SwapChainDescription () {
				BufferCount			=	1,
				ModeDescription		=	new ModeDescription( parameters.Width, parameters.Height, new Rational(60, 1), Format.R8G8B8A8_UNorm ),
				IsWindowed			=	true,
				OutputHandle		=	window2.Handle,
				SampleDescription	=	new SampleDescription(parameters.MsaaLevel, 0),
				SwapEffect			=	SwapEffect.Discard,
				Usage				=	Usage.RenderTargetOutput,
				Flags				=	SwapChainFlags.None,
			};


			d3dDevice	=	new D3D.Device( adapter, deviceFlags, featureLevel );


			using ( var factory = adapter.GetParent<Factory>() ) {
			
				swapChain1	=	new SwapChain( factory, d3dDevice, swapChainDesc1 );
				swapChain2	=	new SwapChain( factory, d3dDevice, swapChainDesc2 );

				//factory.MakeWindowAssociation( new IntPtr(0), WindowAssociationFlags.None );
				factory.MakeWindowAssociation( window1.Handle, WindowAssociationFlags.IgnoreAll | WindowAssociationFlags.IgnoreAltEnter );
				factory.MakeWindowAssociation( window2.Handle, WindowAssociationFlags.IgnoreAll | WindowAssociationFlags.IgnoreAltEnter );
			}


			clientWidth		=	window1.ClientSize.Width;
			clientHeight	=	window1.ClientSize.Height;
		}
示例#10
0
		public void AddOwnedFormTest ()
		{
			Form parent = new Form ();
			parent.ShowInTaskbar = false;
			parent.Text = "NewParent";
			Form ownedForm = new Form ();
			ownedForm.ShowInTaskbar = false;
			ownedForm.Text = "Owned Form";
			parent.AddOwnedForm (ownedForm);
			ownedForm.Show ();
			Assert.AreEqual ("NewParent", ownedForm.Owner.Text, "#41");
			ownedForm.Dispose ();
			parent.Dispose ();
		}