ACAT.Lib.Core.Utility.WindowActiveWatchdog.focusThisForm C# (CSharp) Метод

focusThisForm() приватный Метод

Sets focus to the form
private focusThisForm ( ) : void
Результат void
        private void focusThisForm()
        {
            Log.Debug();
            try
            {
                if (_form != null && _form.Visible && _form.WindowState != FormWindowState.Minimized)
                {
                    Log.Debug("Activating form " + getFormName());
                    try
                    {
                        _form.Invoke(new MethodInvoker(delegate()
                        {
                            // this is a windows defect.  If topmost
                            // is already true, it has not effect.
                            // so we set it to false and then to true
                            _form.TopMost = false;
                            _form.TopMost = true;

                            Windows.SetForegroundWindow(_form.Handle);

                            _form.Select();
                            _form.Activate();
                            _form.Focus();
                        }));
                    }
                    catch (Exception ex)
                    {
                        Log.Exception(ex);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Debug(ex.ToString());
            }

            Log.Debug("Returning");
        }