本文整理汇总了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;
}
示例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;
}
示例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);
}
}
示例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;
}
}
}
示例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;
}
});
}
示例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 );
}
示例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);
}
}
}
示例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;
}
示例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;
}
示例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);
}
}
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}