当前位置: 首页>>代码示例>>C#>>正文


C# Control.FindForm方法代码示例

本文整理汇总了C#中System.Windows.Forms.Control.FindForm方法的典型用法代码示例。如果您正苦于以下问题:C# Control.FindForm方法的具体用法?C# Control.FindForm怎么用?C# Control.FindForm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.Control的用法示例。


在下文中一共展示了Control.FindForm方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FindParentCardView

 public static CardView FindParentCardView(Control control)
 {
     Control parent = control.Parent;
       while(parent != control.FindForm() && !(parent is CardView))
     parent = parent.Parent;
       return parent as CardView;
 }
开发者ID:calvinkwong,项目名称:pol-the-game,代码行数:7,代码来源:GameViewHelper.cs

示例2: ShowDialog

 /// <summary>
 /// Shows a dialog box.
 /// If the owner of the dialog is a popup window, then this method uses <see cref="FormUtil.FindTopLevelOwner"/> 
 /// to find the appropriate main window to own the dialog, and after the dialog is closed, sets the focus back 
 /// to the correct control.
 /// </summary>
 public static DialogResult ShowDialog(Control owner, Form dialog)
 {
     Form ownerForm = null;
     if (null != owner)
     {
         ownerForm = owner.FindForm();
     }
     var topLevelOwner = FindTopLevelOwner(owner);
     Control activeControl = null;
     if (null != ownerForm && ownerForm.ContainsFocus)
     {
         activeControl = ownerForm.ActiveControl;
     }
     var dialogResult = dialog.ShowDialog(topLevelOwner);
     if (null != activeControl)
     {
         if (ownerForm != topLevelOwner)
         {
             // Put the focus first on the window which was the owner of the dialog box.
             // Otherwise when the ownerForm is closed, the focus will go to a different application
             topLevelOwner.Focus();
             // Then put the focus on the control which had the focus before the dialog came up
             activeControl.Focus();
         }
     }
     return dialogResult;
 }
开发者ID:lgatto,项目名称:proteowizard,代码行数:33,代码来源:FormUtil.cs

示例3: WPopUpFormBase

		/// <summary>
		/// Default constructor.
		/// </summary>
		/// <param name="parent"></param>
		public WPopUpFormBase(Control parent)
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
			m_Parent = parent;
			m_ParentForm = m_Parent.FindForm();
			
			if(Form.ActiveForm != null && Form.ActiveForm.IsMdiContainer){
				m_MdiParent = Form.ActiveForm;

				m_MdiParent.LostFocus += new System.EventHandler(this.ParentLostFocus);
				m_MdiParent.MouseDown += new System.Windows.Forms.MouseEventHandler(this.ParentFormMouseClick);
				m_MdiParent.Move      += new System.EventHandler(this.ParentFormMoved);
			}
						
			m_ParentForm.LostFocus += new System.EventHandler(this.ParentLostFocus);
			m_ParentForm.MouseDown += new System.Windows.Forms.MouseEventHandler(this.ParentFormMouseClick);
			m_ParentForm.Move      += new System.EventHandler(this.ParentFormMoved);

			if(!object.ReferenceEquals(m_Parent.Parent,m_ParentForm)){
				m_Parent.Parent.MouseDown += new System.Windows.Forms.MouseEventHandler(this.ParentFormMouseClick);
			}

        }
开发者ID:aureliopires,项目名称:gisa,代码行数:34,代码来源:WPopUpFormBase.cs

示例4: _Find

        private void _Find(Control control)
        {
            if (_control != null)
            {
                if (__trace)
                    Trace.WriteLine("ControlFindForm remove ParentChanged event for control {0}", _control.GetType().Name);
                _control.ParentChanged -= Control_ParentChanged;
                _control = null;
            }

            Form form = control.FindForm();
            if (form != null)
            {
                if (__trace)
                    Trace.WriteLine("ControlFindForm found form");
                _result(form);
            }
            else
            {
                while (true)
                {
                    Control parent = control.Parent;
                    if (parent == null)
                    {
                        if (__trace)
                            Trace.WriteLine("ControlFindForm add ParentChanged event for control {0}", control.GetType().Name);
                        control.ParentChanged += Control_ParentChanged;
                        _control = control;
                        break;
                    }
                    control = parent;
                }
            }
        }
开发者ID:labeuze,项目名称:source,代码行数:34,代码来源:ControlFindForm.cs

示例5: Form

        void IDisplayHandler.OnFullscreenModeChange(IWebBrowser browserControl, IBrowser browser, bool fullscreen)
        {
            var chromiumWebBrowser = (ChromiumWebBrowser)browserControl;

            chromiumWebBrowser.InvokeOnUiThreadIfRequired(() =>
            {
                if (fullscreen)
                {
                    parent = chromiumWebBrowser.Parent;

                    parent.Controls.Remove(chromiumWebBrowser);

                    fullScreenForm = new Form();
                    fullScreenForm.FormBorderStyle = FormBorderStyle.None;
                    fullScreenForm.WindowState = FormWindowState.Maximized;

                    fullScreenForm.Controls.Add(chromiumWebBrowser);

                    fullScreenForm.ShowDialog(parent.FindForm());
                }
                else
                {
                    fullScreenForm.Controls.Remove(chromiumWebBrowser);

                    parent.Controls.Add(chromiumWebBrowser);

                    fullScreenForm.Close();
                    fullScreenForm.Dispose();
                    fullScreenForm = null;
                }
            });
        }
开发者ID:Creo1402,项目名称:CefSharp,代码行数:32,代码来源:DisplayHandler.cs

示例6: OverlayWindow

        /// <summary>
        /// Erzeugt eine neue Überlagerung.
        /// </summary>
        /// <param name="reference">Dieses Steuerelement dient als Bezugspunkt.</param>
        /// <exception cref="ArgumentNullException">Es wurde kein Bezugspunkt angegeben.</exception>
        public OverlayWindow( Control reference )
        {
            // Validate
            if (reference == null)
                throw new ArgumentNullException( "reference" );

            // Remember
            m_ReferenceForm = reference.FindForm();
            m_Reference = reference;

            // Load designer stuff
            InitializeComponent();

            // Finish
            if (UseLegacyOverlay)
                picOSD.Dock = DockStyle.Fill;
            else
                TransparencyKey = TTXPage.TransparentColor.Color;

            // Attach location changes
            m_ReferenceForm.LocationChanged += AdaptChanges;
            m_ReferenceForm.SizeChanged += AdaptChanges;
            m_Reference.LocationChanged += AdaptChanges;
            m_Reference.SizeChanged += AdaptChanges;

            // Adjust to initial size
            AdaptChanges( m_Reference, EventArgs.Empty );
        }
开发者ID:davinx,项目名称:DVB.NET---VCR.NET,代码行数:33,代码来源:OverlayWindow.cs

示例7: Remove

        public static void Remove(Control.ControlCollection coll, Control item)
        {
            if ((coll != null) && (item != null))
            {
                Button tempButton = null;
                Form parentForm = item.FindForm();

                if (parentForm != null)
                {
                    // Create a hidden, temporary button
                    tempButton = new Button();
                    tempButton.Visible = false;

                    // Add this temporary button to the parent form
                    parentForm.Controls.Add(tempButton);

                    // Must ensure that temp button is the active one
                    parentForm.ActiveControl = tempButton;
                }

                // Remove our target control
                coll.Remove(item);

                if (parentForm != null)
                {
                    // Remove the temporary button
                    tempButton.Dispose();
                    parentForm.Controls.Remove(tempButton);
                }
            }
        }
开发者ID:krishnais,项目名称:ProfileSharp,代码行数:31,代码来源:ControlHelper.cs

示例8: FindMySnapManager

        public static SnapManager FindMySnapManager(Control me)
        {
            if (!(me is ISnapObstacleHost))
            {
                throw new ArgumentException("must be called with a Control that implements ISnapObstacleHost");
            }

            ISnapManagerHost ismh;

            ismh = me as ISnapManagerHost;

            if (ismh == null)
            {
                ismh = me.FindForm() as ISnapManagerHost;
            }

            SnapManager sm;
            if (ismh != null)
            {
                sm = ismh.SnapManager;
            }
            else
            {
                sm = null;
            }

            return sm;
        }
开发者ID:leejungho2,项目名称:xynotecgui,代码行数:28,代码来源:SnapManager.cs

示例9: GetTipSize

		public static Size GetTipSize(Control control, Graphics graphics, TipSection tipData) {
			Size tipSize = Size.Empty;
			SizeF tipSizeF = SizeF.Empty;

			if (workingArea == RectangleF.Empty) {
				Form ownerForm = control.FindForm();
				if (ownerForm.Owner != null) {
					ownerForm = ownerForm.Owner;
				}

				workingArea = Screen.GetWorkingArea(ownerForm);
			}

			PointF screenLocation = control.PointToScreen(Point.Empty);
			SizeF maxLayoutSize = new SizeF(workingArea.Right - screenLocation.X - HorizontalBorder * 2, workingArea.Bottom - screenLocation.Y - VerticalBorder * 2);

			if (maxLayoutSize.Width > 0 && maxLayoutSize.Height > 0) {
				graphics.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;

				tipData.SetMaximumSize(maxLayoutSize);
				tipSizeF = tipData.GetRequiredSize();
				tipData.SetAllocatedSize(tipSizeF);

				tipSizeF += new SizeF(HorizontalBorder * 2, VerticalBorder * 2);
				tipSize = Size.Ceiling(tipSizeF);
			}

			if (control.ClientSize != tipSize) {
				control.ClientSize = tipSize;
			}

			return tipSize;
		}
开发者ID:GodLesZ,项目名称:svn-dump,代码行数:33,代码来源:TipPainter.cs

示例10: RemoveAll

        public static void RemoveAll(Control control)
        {
            if ((control != null) && (control.Controls.Count > 0))
            {
                Button tempButton = null;
                Form parentForm = control.FindForm();

                if (parentForm != null)
                {
                    // Create a hidden, temporary button
                    tempButton = new Button();
                    tempButton.Visible = false;

                    // Add this temporary button to the parent form
                    parentForm.Controls.Add(tempButton);

                    // Must ensure that temp button is the active one
                    parentForm.ActiveControl = tempButton;
                }

              				// Remove all entries from target
                control.Controls.Clear();

                if (parentForm != null)
                {
                    // Remove the temporary button
                    tempButton.Dispose();
                    parentForm.Controls.Remove(tempButton);
                }
            }
        }
开发者ID:krishnais,项目名称:ProfileSharp,代码行数:31,代码来源:ControlHelper.cs

示例11: GetImage

    public static Image GetImage(Control c_)
    {
      Graphics g = null;
      Image ret = null;
      try
      {
        if (c_ is Form)
          c_.BringToFront();
        else
          c_.FindForm().BringToFront();

        Application.DoEvents();

        g = c_.CreateGraphics();
        ret = new Bitmap(c_.ClientRectangle.Width, c_.ClientRectangle.Height, g);
        Graphics g2 = Graphics.FromImage(ret);
        IntPtr dc1 = g.GetHdc();
        IntPtr dc2 = g2.GetHdc();
        BitBlt(dc2, 0, 0, c_.ClientRectangle.Width, c_.ClientRectangle.Height, dc1, 0, 0, 13369376);
        g.ReleaseHdc(dc1);
        g2.ReleaseHdc(dc2);
      }
      finally
      {
        if (g != null)
          g.Dispose();
      }

      return ret;
    }
开发者ID:heimanhon,项目名称:researchwork,代码行数:30,代码来源:Util.cs

示例12: FindParentPlayerStatusView

 public static PlayerStatusView FindParentPlayerStatusView(Control control)
 {
     Control parent = control.Parent;
       while(parent != control.FindForm() && !(parent is PlayerStatusView))
     parent = parent.Parent;
       return parent as PlayerStatusView;
 }
开发者ID:calvinkwong,项目名称:pol-the-game,代码行数:7,代码来源:GameViewHelper.cs

示例13: HelpBtn2

 public HelpBtn2(Control Src) {
     Control C = new Control();
     C.Parent = (this.form = Src.FindForm());
     C.Capture = true;
     C.Cursor = Cursors.Help;
     C.MouseDown += new MouseEventHandler(C_MouseDown);
 }
开发者ID:HiraokaHyperTools,项目名称:OCRPattern,代码行数:7,代码来源:HelpBtn.cs

示例14: BeginDrag

		protected bool BeginDrag(Control c)
		{
			// Avoid re-entrance;
			if (m_dragControl != null)
				return false;

			m_startMousePosition = Control.MousePosition;

			if (!User32.DragDetect(c.Handle, StartMousePosition))
				return false;

			m_dragControl = c;
			c.FindForm().Capture = true;
			AssignHandle(c.FindForm().Handle);
			Application.AddMessageFilter(this);
			return true;
		}
开发者ID:tropology,项目名称:ceptr,代码行数:17,代码来源:DragHandlerBase.cs

示例15: GetTipSize

		public static Size GetTipSize(Control control, Graphics graphics, TipSection tipData)
		{
			Size tipSize = Size.Empty;
			SizeF tipSizeF = SizeF.Empty;
			
			if (workingArea == RectangleF.Empty) {
				Form ownerForm = control.FindForm();
				if (ownerForm.Owner != null) {
					ownerForm = ownerForm.Owner;
				}
				
				workingArea = Screen.GetWorkingArea(ownerForm);
			}
			
			PointF screenLocation = control.PointToScreen(Point.Empty);
			SizeF maxLayoutSize = new SizeF(workingArea.Right /*- screenLocation.X*/ - HorizontalBorder * 2,
			                                workingArea.Bottom /*- screenLocation.Y*/ - VerticalBorder * 2);
			
			float global_max_x = workingArea.Right - HorizontalBorder * 2;
			
			if (maxLayoutSize.Width > 0 && maxLayoutSize.Height > 0) {
				/*graphics.TextRenderingHint =
				TextRenderingHint.AntiAliasGridFit;*/
				tipData.GlobalMaxX = global_max_x;
				tipData.SetMaximumSize(maxLayoutSize);
				//if (tipData.LeftOffset > 0) 
				//	control.Left = control.Left - tipData.LeftOffset;
				tipSizeF = tipData.GetRequiredSize();
				tipData.SetAllocatedSize(tipSizeF);
				
				tipSizeF += new SizeF(HorizontalBorder * 2,
				                      VerticalBorder   * 2);
				tipSize = Size.Ceiling(tipSizeF);
			}
			if (control is ICSharpCode.TextEditor.Gui.InsightWindow.PABCNETInsightWindow)
			{
				Rectangle rect = Rectangle.Ceiling(workingArea);
				Point pt = (control as ICSharpCode.TextEditor.Gui.InsightWindow.PABCNETInsightWindow).GetCusorCoord();
				if (pt.X + tipSize.Width > rect.Width)
				{
					control.Location = new Point(rect.Width-tipSize.Width,pt.Y);
				}
			}
			else
			{
				Rectangle rect = Rectangle.Ceiling(workingArea);
				Point pt = control.Location;
				if (pt.X + tipSize.Width > rect.Width)
				{
					control.Location = new Point(rect.Width-tipSize.Width,pt.Y);
				}
			}
			if (control.ClientSize != tipSize) {
				control.ClientSize = tipSize;
			}
			
			return tipSize;
		}
开发者ID:lisiynos,项目名称:pascalabcnet,代码行数:58,代码来源:TipPainter.cs


注:本文中的System.Windows.Forms.Control.FindForm方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。