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


C# Form.Focus方法代码示例

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


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

示例1: Show

        /// <summary>
        /// Draws a MessageBox that always stays on top with a title, selectable buttons and an icon
        /// </summary>
        static public DialogResult Show(string message, string title,
            MessageBoxButtons buttons,MessageBoxIcon icon)
        {
            // Create a host form that is a TopMost window which will be the 

            // parent of the MessageBox.

            Form topmostForm = new Form();
            // We do not want anyone to see this window so position it off the 

            // visible screen and make it as small as possible

            topmostForm.Size = new System.Drawing.Size(1, 1);
            topmostForm.StartPosition = FormStartPosition.Manual;
            System.Drawing.Rectangle rect = SystemInformation.VirtualScreen;
            topmostForm.Location = new System.Drawing.Point(rect.Bottom + 10,
                rect.Right + 10);
            topmostForm.Show();
            // Make this form the active form and make it TopMost

            topmostForm.Focus();
            topmostForm.BringToFront();
            topmostForm.TopMost = true;
            // Finally show the MessageBox with the form just created as its owner

            DialogResult result = MessageBox.Show(topmostForm, message, title,
                buttons,icon);
            topmostForm.Dispose(); // clean it up all the way


            return result;
        }
开发者ID:matalangilbert,项目名称:stromohab-2008,代码行数:35,代码来源:TopMostMessageBox.cs

示例2: YamuiSmokeScreen

        public YamuiSmokeScreen(Form owner, Rectangle pageRectangle)
        {
            SetStyle(ControlStyles.UserPaint |
                ControlStyles.AllPaintingInWmPaint |
                ControlStyles.ResizeRedraw |
                ControlStyles.OptimizedDoubleBuffer, true);

            _pageRectangle = pageRectangle;
            FormBorderStyle = FormBorderStyle.None;
            ControlBox = false;
            ShowInTaskbar = false;
            StartPosition = FormStartPosition.Manual;
            Location = owner.PointToScreen(_pageRectangle.Location);
            _sizeDifference = new Point(owner.Width - _pageRectangle.Width, owner.Height - _pageRectangle.Height);
            ClientSize = new Size(owner.Width - _sizeDifference.X, owner.Height - _sizeDifference.Y);
            owner.LocationChanged += Cover_LocationChanged;
            owner.ClientSizeChanged += Cover_ClientSizeChanged;
            owner.VisibleChanged += Cover_OnVisibleChanged;

            // Disable Aero transitions, the plexiglass gets too visible
            if (Environment.OSVersion.Version.Major >= 6) {
                int value = 1;
                DwmApi.DwmSetWindowAttribute(owner.Handle, DwmApi.DwmwaTransitionsForcedisabled, ref value, 4);
            }

            base.Opacity = 0d;
            Show(owner);
            owner.Focus();
        }
开发者ID:jcaillon,项目名称:YamuiFramework,代码行数:29,代码来源:YamuiSmokeScreen.cs

示例3: bringToFront

        // [focus]
        /// <summary>
        /// bring form to foreground </summary>
        public static void bringToFront(Form form)
        {
            Program.log.write("bringToFront");
            Tick.timer(500, (t, args) =>
            {
                if (t is Timer)
                {
                    Timer timer = t as Timer;

                    Program.log.write("bringToFront: tick");
                    timer.Enabled = false;

                    //diagram bring to top hack in windows
                    if (form.WindowState == FormWindowState.Minimized)
                    {
                        form.WindowState = FormWindowState.Normal;
                    }

            #if !MONO
                    SetForegroundWindow(form.Handle.ToInt32());
            #endif
                    form.TopMost = true;
                    form.Focus();
                    form.BringToFront();
                    form.TopMost = false;
                    form.Activate();
                }
            });
        }
开发者ID:pekand,项目名称:infinite-diagram,代码行数:32,代码来源:Media.cs

示例4: InstanceFormChild

        public static void InstanceFormChild(Form frmChild, Form frmParent, bool modal)
        {
            if (frmParent != null)
                foreach (var item in frmParent.MdiChildren)
                {
                    if (item.GetType() == frmChild.GetType())
                    {
                        frmChild.Focus();
                        frmChild.BringToFront();
                        frmChild.Activate();
                        return;
                    }
                }

            frmChild.ShowInTaskbar = false;

            if (modal)
            {
                frmChild.TopLevel = true;
                frmChild.ShowDialog();
            }
            else
            {
                if (frmParent != null)
                    frmChild.MdiParent = frmParent;

                frmChild.Show();
            }
        }
开发者ID:tonfranco,项目名称:LR,代码行数:29,代码来源:FormUtil.cs

示例5: BringToFront

 public static void BringToFront(Form form)
 {
     // Make this form the active form
     form.TopMost = true;
     form.Focus();
     form.BringToFront();
     form.TopMost = false;
 }
开发者ID:MartyIX,项目名称:SoTh,代码行数:8,代码来源:BringToFront.cs

示例6: Form2

 public Form2(Form parentForm)
 {
     InitializeComponent();
     frmM = parentForm;
     DialogResult res = openFileDialog1.ShowDialog();
     if (res == DialogResult.OK)
     {
         this.BackgroundImage = new Bitmap(openFileDialog1.FileName);
     }
     frmM.Focus();
 }
开发者ID:vinothvoice,项目名称:GlassyWriter,代码行数:11,代码来源:Form2.cs

示例7: ShowForm

        public void ShowForm(Form frm)
        {
            this.formPanel.Controls.Clear();

            frm.TopLevel = false;
            frm.FormBorderStyle = FormBorderStyle.None;
            frm.Dock = DockStyle.Fill;
            frm.Visible = true;
            //frm.Parent=this;
            formPanel.Controls.Add(frm);
            this.Text = frm.Text;
            frm.Focus();
        }
开发者ID:25cm,项目名称:HelloWorld,代码行数:13,代码来源:Menu.cs

示例8: Show

 public static DialogResult Show(string message, string title, MessageBoxButtons buttons)
 {
     Form topmostForm = new Form();
     topmostForm.Size = new System.Drawing.Size(1, 1);
     topmostForm.StartPosition = FormStartPosition.Manual;
     System.Drawing.Rectangle rect = SystemInformation.VirtualScreen;
     topmostForm.Location = new System.Drawing.Point(rect.Bottom + 10, rect.Right + 10);
     topmostForm.Show();
     topmostForm.Focus();
     topmostForm.BringToFront();
     topmostForm.TopMost = true;
     DialogResult result = MessageBox.Show(topmostForm, message, title, buttons);
     topmostForm.Dispose();
     return result;
 }
开发者ID:benhejl,项目名称:SWENG500_Team1,代码行数:15,代码来源:TopMostMessageBox.cs

示例9: ActivateForm

        public override void ActivateForm(Form form, DesktopWindow window, IntPtr hwnd)
        {
            if (window == null || window.Handle != form.Handle)
            {
                Log.InfoFormat("[{0}] Activating Main Window - current=({1})", hwnd, window != null ? window.Exe : "?");

                form.BringToFront();
                form.Focus();
                form.Show();
                form.Activate();

                // stop flashing...happens occassionally when switching quickly when activate manuver is fails
                NativeMethods.FlashWindow(form.Handle, NativeMethods.FLASHW_STOP);
            }
        }
开发者ID:mesenger,项目名称:superputty,代码行数:15,代码来源:WindowActivator.cs

示例10: FlashWindow

        public static void FlashWindow(Form win, UInt32 count = UInt32.MaxValue)
        {
            //Don't flash if the window is active
            if (win.Focus()) return;

            FLASHWINFO info = new FLASHWINFO
            {
                hwnd = win.Handle,
                dwFlags = FLASHW_TRAY | FLASHW_TIMERNOFG,
                uCount = count,
                dwTimeout = 0
            };

            info.cbSize = Convert.ToUInt32(Marshal.SizeOf(info));
            FlashWindowEx(ref info);
        }
开发者ID:spb829,项目名称:LoL-Chat-for-Windows,代码行数:16,代码来源:frmMain.cs

示例11: Plexiglass

 public Plexiglass(Form tocover)
 {
     this.BackColor = Color.Black;
     this.Opacity = 0.5;      // Tweak as desired
     this.FormBorderStyle = FormBorderStyle.None;
     this.ControlBox = false;
     this.ShowInTaskbar = false;
     this.StartPosition = FormStartPosition.Manual;
     this.AutoScaleMode = AutoScaleMode.None;
     this.Location = tocover.PointToScreen(Point.Empty);
     this.ClientSize = tocover.ClientSize;
     tocover.LocationChanged += Cover_LocationChanged;
     tocover.ClientSizeChanged += Cover_ClientSizeChanged;
     this.Show(tocover);
     tocover.Focus();
 }
开发者ID:Razsiel,项目名称:INF1FB_1.4_Ontwikkeling,代码行数:16,代码来源:PlexiglassCover.cs

示例12: TopMostFormFix

        public TopMostFormFix()
        {
            m_form = new Form();

            // We do not want anyone to see this window so position it off the
            // visible screen and make it as small as possible
            m_form.Size = new System.Drawing.Size(1, 1);
            m_form.StartPosition = FormStartPosition.Manual;
            m_form.ShowInTaskbar = false;
            m_form.Location = new Point(0, SystemInformation.VirtualScreen.Right + 10);
            m_form.Show();

            // Make this form the active form and make it TopMost
            m_form.Focus();
            m_form.BringToFront();
            m_form.TopMost = true;
        }
开发者ID:configit-open-source,项目名称:csmerge,代码行数:17,代码来源:TopMostFormFix.cs

示例13: smethod_1

 // Token: 0x06002EFA RID: 12026
 // RVA: 0x00130E14 File Offset: 0x0012F014
 public static DialogResult smethod_1(string string_0, string string_1, MessageBoxButtons messageBoxButtons_0, MessageBoxIcon messageBoxIcon_0, MessageBoxDefaultButton messageBoxDefaultButton_0)
 {
     SplashScreen.smethod_3();
     Form form = new Form();
     form.ShowInTaskbar = false;
     form.Size = new Size(1, 1);
     form.StartPosition = FormStartPosition.Manual;
     Rectangle virtualScreen = SystemInformation.VirtualScreen;
     form.Location = new Point(virtualScreen.Bottom + 10, virtualScreen.Right + 10);
     form.Show();
     form.Focus();
     form.BringToFront();
     form.TopMost = true;
     DialogResult result = MessageBox.Show(form, string_0, string_1, messageBoxButtons_0, messageBoxIcon_0);
     form.Dispose();
     return result;
 }
开发者ID:newchild,项目名称:Project-DayZero,代码行数:19,代码来源:Class792.cs

示例14: EnqueRetainFocusCallback

        /// <summary>
        /// Invoke with a form and a number of seconds and the helper will attempt to keep the form focused
        /// for that period of time.
        /// </summary>
        /// <param name="form">The form to retain focus on</param>
        /// <param name="seconds">The number of seconds to retain focus for</param>
        /// <remarks>This method uses the <see cref="ThreadPool" /> to asynchronously maintain focus.</remarks>
        public static void EnqueRetainFocusCallback(Form form, int seconds)
        {
            WaitCallback callback = delegate
                                        {
                                            try
                                            {
                                                for (int i = 0; i < (seconds*10); i++)
                                                {
                                                    Thread.Sleep(100);

                                                    // must ensure the form hasn't be disposed (in case the user closes the 
                                                    // form before the retain focus time has expired).

                                                    if (form.IsDisposed || form.Disposing) return;

                                                    if (!form.IsHandleCreated) continue;

                                                    form.Invoke(new ThreadStart(delegate
                                                                                    {
                                                                                        if (form.IsDisposed ||
                                                                                            form.Disposing) return;
                                                                                        form.Focus();
                                                                                    }));
                                                }
                                            }
                                            catch (Exception ex)
                                            {
                                                throw;
                                                // TODO: fix this
                                                /*if (IoC.IsInitialized)
                                                {
                                                    ILogger logger =
                                                        IoC.Resolve<ILoggerFactory>().Create(form.GetType());
                                                    logger.Error(
                                                        "Exception raised while attempting to maintain form focus, aborting callback",
                                                        ex);
                                                }
                                                return;*/
                                            }
                                        };

            ThreadPool.QueueUserWorkItem(callback);
        }
开发者ID:tiwariritesh7,项目名称:devdefined-tools,代码行数:50,代码来源:FocusHelper.cs

示例15: FormAcikmi

 private void FormAcikmi(Form AcilacakForm)
 {
     bool Acikmi = false;
     for (int i = 0; i < this.MdiChildren.Length; i++)
     {
         if (AcilacakForm.Name == MdiChildren[i].Name)
         {
             AcilacakForm.Focus();
             Acikmi = true;
         }
     }
     if (Acikmi == false)
     {
         AcilacakForm.MdiParent = this;
         AcilacakForm.Show();
     }
     else
     {
         AcilacakForm.Dispose();
     }
 }
开发者ID:AlptugYaman,项目名称:VideoMarket,代码行数:21,代码来源:frmAnaSayfa.cs


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