示例#1
0
 void _OnGotLostFocus(bool got, _SciTextBox tb)
 {
     if (!_cRegex.Checked)
     {
         return;
     }
     if (got)
     {
         //use timer to avoid temporary focus problems, for example when tabbing quickly or closing active Regex window
         ATimer.After(70, _ => { if (tb.Focused)
                                 {
                                     _ShowRegexInfo(tb, false);
                                 }
                      });
     }
     else
     {
         if (_regexWindow.Window.Visible)
         {
             var c = AWnd.ThisThread.FocusedControl;
             if (c == null || (c != _tFind && c != _tReplace && c != _regexWindow.Window && c.TopLevelControl != _regexWindow.Window))
             {
                 _regexWindow.Hide();
             }
         }
     }
 }
示例#2
0
 void _StartTimer()
 {
     _timer ??= new ATimer(t => {
         if (_editFlag)
         {
             BeginEdit();
         }
         _editFlag = false;
     });
     _timer.After(500);
 }
示例#3
0
文件: FMain.cs 项目: alexfordc/Au
    protected override void OnVisibleChanged(EventArgs e)
    {
        //AOutput.Write("OnVisibleChanged", Visible, ((AWnd)this).IsVisible); //true, false
        bool visible = Visible;

        //note: we don't use OnLoad. It's unreliable, sometimes not called, eg when made visible from outside.
        if (visible && Program.Loaded == EProgramState.LoadedWorkspace)
        {
            //APerf.Next();
            _StartProfileOptimization();             //fast
            APerf.Next('v');

            Panels.PanelManager.ZGetPanel(Panels.Output).Visible = true;             //else AOutput.Write would not auto set visible until the user makes it visible, because handle not created if invisible

            var hm = Api.GetSystemMenu(_Hwnd, false);
            Api.AppendMenu(hm, 0, c_menuid_Exit, "&Exit");

            Application.AddMessageFilter(new _AppMessageFilter());

            Panels.Files.ZOpenDocuments();

            Program.Loaded = EProgramState.LoadedUI;
            Load?.Invoke(this, EventArgs.Empty);

            APerf.Next('o');
            CodeInfo.UiLoaded();

#if TRACE
            ATimer.After(1, _ => {
                var s = CommandLine.TestArg;
                if (s != null)
                {
                    AOutput.Write(ATime.PerfMicroseconds - Convert.ToInt64(s));
                }
                //APerf.NW('V');

                //EdDebug.PrintTabOrder(this);
            });
#endif
        }

        if (!visible)
        {
            CodeInfo.Stop();
        }
        UacDragDrop.AdminProcess.Enable(visible);

        base.OnVisibleChanged(e);
    }
示例#4
0
文件: Program.cs 项目: alexfordc/Au
 static void _Hook()
 {
     s_hook = AHookWin.ThreadCbt(m => {
         //AOutput.Write(m.code, m.wParam, m.lParam);
         //switch(m.code) {
         //case HookData.CbtEvent.ACTIVATE:
         //case HookData.CbtEvent.SETFOCUS:
         //	AOutput.Write((AWnd)m.wParam);
         //	AOutput.Write(AWnd.Active);
         //	AOutput.Write(AWnd.ThisThread.Active);
         //	AOutput.Write(AWnd.Focused);
         //	AOutput.Write(AWnd.ThisThread.Focused);
         //	break;
         //}
         if (m.code == HookData.CbtEvent.ACTIVATE)
         {
             var w = (AWnd)m.wParam;
             if (!w.HasExStyle(WS2.NOACTIVATE))
             {
                 //AOutput.Write(w);
                 //AOutput.Write(w.ExStyle);
                 //Api.SetForegroundWindow(w); //does not work
                 ATimer.After(1, _ => {
                     if (s_hook == null)
                     {
                         return;
                     }
                     //AOutput.Write(AWnd.Active);
                     //AOutput.Write(AWnd.ThisThread.Active);
                     bool isActive = w == AWnd.Active, activate = !isActive && w == AWnd.ThisThread.Active;
                     if (isActive || activate)
                     {
                         s_hook.Dispose(); s_hook = null;
                     }
                     if (activate)
                     {
                         Api.SetForegroundWindow(w);
                         //w.ActivateLL(); //no, it's against Windows rules, and works differently with meta outputPath
                         //Before starting task, editor calls AllowSetForegroundWindow. But if clicked etc a window after that:
                         //	SetForegroundWindow fails always or randomly;
                         //	Activate[LL] fails if that window is of higher UAC IL, unless the foreground lock timeout is 0.
                     }
                 });
             }
         }
         return(false);
     });
 }
示例#5
0
文件: FMain.cs 项目: alexfordc/Au
    public static void ZRunApplication()
    {
        var f = new FMain();

#if TRACE
        ATimer.After(1, _ => APerf.NW('P'));
#endif
        if (!Program.Settings.runHidden || CommandLine.StartVisible)
        {
            Application.Run(f);
        }
        else
        {
            Application.Run();
        }
    }
示例#6
0
        public int Show(AWnd owner)
        {
            if (Api.GetFocus() == default)              //prevent activating the menu window on click
            {
                ATimer.After(1, _ => {
                    var w = AWnd.Find("", "#32768", WOwner.ThisThread);                     //find visible classic menu window of this thread
                    if (!w.Is0)
                    {
                        w.SetExStyle(WS2.NOACTIVATE, WSFlags.Add);
                    }
                });
            }
            var p = AMouse.XY;

            return(Api.TrackPopupMenuEx(_h, Api.TPM_RETURNCMD, p.x, p.y, owner));
        }
示例#7
0
文件: PanelInfo.cs 项目: alexfordc/Au
    protected override void OnLoad(EventArgs e)
    {
        var z = _sci.Z;

        z.StyleBackColor(Sci.STYLE_DEFAULT, 0xF0F0F0);
        z.StyleFont(Sci.STYLE_DEFAULT, Font);
        z.MarginWidth(1, 4);
        z.StyleClearAll();
        //_sci.Call(Sci.SCI_SETHSCROLLBAR);
        _sci.Call(Sci.SCI_SETVSCROLLBAR);

        Program.MousePosChangedWhenProgramVisible += _MouseInfo;
        ATimer.After(50, _ => { ZSetAboutInfo(); _html.Show(); });

        base.OnLoad(e);
    }
示例#8
0
        private void Editor_LostFocus(object sender, EventArgs e)
        {
            var c = CurrentEditor;

            if (c != null && !ContainsFocus && c.TopLevelControl == Form.ActiveForm)
            {
                //async to avoid a hard-to-debug ObjectDisposedException
                ATimer.After(100, _ =>
                {
                    if (CurrentEditor != null && !ContainsFocus)
                    {
                        CurrentEditorOwner.EndEdit(true);
                        UpdateView();
                    }
                });
            }
        }
示例#9
0
            internal void InitDockStateFromXML(XElement x)
            {
                Enum.TryParse(x.Attr("state"), out this.DockState);
                bool hide = x.HasAttr("hide"), floating = this.DockState == _DockState.Floating;

                if (hide || floating)
                {
                    this.SavedVisibleDockState = this.DockState;
                    this.DockState             = _DockState.Hidden;
                    switch (this)
                    {
                    case _Panel gp:
                        gp.Content.Visible = false;
                        break;

                    case _Tab gt:
                        foreach (var v in gt.Items)
                        {
                            v.Content.Visible = false;
                        }
                        break;
                    }
                    if (!hide)
                    {
                        PaintEventHandler eh = null;
                        eh = (object sender, PaintEventArgs e) => {
                            _manager.Paint -= eh;
                            //SetDockState(_DockState.Floating);
                            ATimer.After(200, _ => SetDockState(_DockState.Floating));
                        };
                        _manager.Paint += eh;
                    }
                }
                this.SavedFloatingBounds = _RectFromString(x.Attr("rectFloating"));
                if (!this.IsTabbedPanel || floating)
                {
                    Enum.TryParse(x.Attr("captionAt"), out this.CaptionAt);
                }
            }
示例#10
0
    public static void OnProgramLoaded()
    {
        AWnd.More.UacEnableMessages(Api.WM_COPYDATA, Api.WM_USER, Api.WM_CLOSE);
        AWnd.More.RegisterWindowClass("Au.Editor.Msg", _WndProc);
        _msgWnd = AWnd.More.CreateMessageOnlyWindow("Au.Editor.Msg");

        if (_importWorkspace != null || _importFiles != null)
        {
            ATimer.After(10, _ => {
                try {
                    Program.MainForm.ZShowAndActivate();
                    if (_importWorkspace != null)
                    {
                        Program.Model.ImportWorkspace(_importWorkspace);
                    }
                    else
                    {
                        Program.Model.ImportFiles(_importFiles);
                    }
                }
                catch (Exception ex) { AOutput.Write(ex.Message); }
            });
        }
    }
示例#11
0
            internal void ShowContextMenu(Point p)
            {
                var  gp    = this as _Panel;
                bool isTab = this is _Tab gt;
                var  state = this.DockState;
                var  m     = new AMenu();

                m.Control.Text = "Menu";

                //dock state
                m.Add("Float\tD-click, drag", o => this.SetDockState(_DockState.Floating)).Enabled      = state != _DockState.Floating;
                m.Add("Dock    \tD-click, Alt+drag", o => this.SetDockState(_DockState.Docked)).Enabled = state != _DockState.Docked;
                //menu.Add("Auto Hide", o => this.SetDockState(_DockState.AutoHide)).Enabled = state != _DockState.AutoHide && !isTab; //not implemented
                m["Hide\tM-click"] = o => this.SetDockState(_DockState.Hidden);

                m.Separator();
                using (m.Submenu("Show Panel")) _manager.ZAddShowPanelsToMenu(m.LastMenuItem.DropDown, false);
                using (m.Submenu("Show Toolbar")) _manager.ZAddShowPanelsToMenu(m.LastMenuItem.DropDown, true);

                m.Separator();
                var k = (!this.IsTabbedPanel || this.IsFloating) ? this : gp.ParentTab;

                //caption edge
                using (m.Submenu("Caption At")) {
                    m["Top"] = o => k._SetCaptionEdge(CaptionEdge.Top); if (k.CaptionAt == CaptionEdge.Top)
                    {
                        m.LastMenuItem.Checked = true;
                    }
                    m["Bottom"] = o => k._SetCaptionEdge(CaptionEdge.Bottom); if (k.CaptionAt == CaptionEdge.Bottom)
                    {
                        m.LastMenuItem.Checked = true;
                    }
                    m["Left"] = o => k._SetCaptionEdge(CaptionEdge.Left); if (k.CaptionAt == CaptionEdge.Left)
                    {
                        m.LastMenuItem.Checked = true;
                    }
                    m["Right"] = o => k._SetCaptionEdge(CaptionEdge.Right); if (k.CaptionAt == CaptionEdge.Right)
                    {
                        m.LastMenuItem.Checked = true;
                    }
                }
                //fixed width/height
                if (this.IsDockedOn(_manager))
                {
                    _AddFixedSize(k.ParentSplit, k);
                    void _AddFixedSize(_Split gs, _Node gn)
                    {
                        if (gs.IsSplitterVisible)
                        {
                            bool fixedSize = gs.IsChildFixedSize(gn);
                            m.Add(gs.IsVerticalSplit ? "Fixed Width" : "Fixed Height", o => gs.SetChildFixedSize(gn, !fixedSize)).Checked = fixedSize;
                        }
                        var gs2 = gs.ParentSplit;

                        if (gs2 != null)
                        {
                            using (m.Submenu("Container")) {
                                m.LastMenuItem.DropDown.Opened += (unu, sed) => {
                                    var osd = new AOsdRect {
                                        Rect = _manager.RectangleToScreen(gs.Bounds), Color = 0x00c000
                                    };
                                    osd.Show();
                                    ATimer.After(1000, _ => osd.Dispose());
                                };
                                _AddFixedSize(gs2, gs);
                            }
                        }
                    }
                }

                //test
                //m.Separator();
                //m["test"] = o =>
                //{
                //};

                //custom
                _manager.ZPanelContextMenu?.Invoke(new ZContextMenuEventArgs(gp, m));

                m.Show(this.ParentControl, p.X, p.Y);
            }
示例#12
0
        /// <summary>
        /// Creates a menu or toolbar item.
        /// </summary>
        /// <param name="x">XML element containing item properties.</param>
        /// <param name="isMenu">false if toolbar item, true if menu item (also if menu bar item).</param>
        ToolStripItem _CreateChildItem(XElement x, bool isMenu)
        {
            string s, tag = x.Name.LocalName;

            if (tag == "sep")
            {
                return new ToolStripSeparator()
                       {
                           Tag = x
                       }
            }
            ;

            ToolStripItem item; ToolStripMenuItem mi;
            bool          isControl = false, needHandler = false;

            if (isMenu)
            {
                mi = new ToolStripMenuItem();

                item = mi;
                if (x.HasElements || x.HasAttr("dd"))
                {
                    _Submenu(x, mi, tag);
                }
                else
                {
                    needHandler = true;
                }
            }
            else if (x.HasAttr("type"))
            {
                isControl = true;
                string cue = x.Attr("cue");
                s = x.Attr("type");
                switch (s)
                {
                case "edit":
                    var ed = new ToolStripSpringTextBox();
                    if (cue != null)
                    {
                        ed.ZSetCueBanner(cue);
                    }
                    item = ed;
                    break;

                case "combo":
                    var combo = new ToolStripSpringComboBox();
                    if (cue != null)
                    {
                        combo.ZSetCueBanner(cue);
                    }
                    item = combo;
                    break;

                default:
                    Debug.Assert(false);
                    return(null);
                }
                if (cue != null)
                {
                    item.AccessibleName = cue;
                }
            }
            else if (x.HasElements || x.HasAttr("dd"))
            {
                ToolStripDropDownItem ddi;
                var handler = _callbacks.GetClickHandler(tag);
                if (handler != null)
                {
                    var sb = new ToolStripSplitButton();
                    sb.ButtonClick += handler;
                    ddi             = sb;
                }
                else
                {
                    ddi = new ToolStripDropDownButton();
                }
                item = ddi;
                _Submenu(x, ddi, tag);
            }
            else
            {
                needHandler = true;
                var b = new ToolStripButton();
                item = b;
            }

            item.Name = tag;
            item.Tag  = x;

            _SetItemProperties(x, item, isMenu, isControl);

            if (needHandler)
            {
                var handler = _callbacks.GetClickHandler(tag);
                if (handler != null)
                {
                    item.Click += handler;
                }
                else
                {
                    ADebug.Print("no handler of " + tag);
                    //return null;
                    //item.Enabled = false;
                    item.Visible = false;
                }
            }

            return(item);
        }

        void _Submenu(XElement x, ToolStripDropDownItem ddItem, string tag)
        {
            var s = x.Attr("dd");

            if (!s.NE())
            {
                ddItem.DropDown = Submenus[s];
            }
            else
            {
                var dd = ddItem.DropDown as ToolStripDropDownMenu;                 //note: not ddItem.DropDown=new ToolStripDropDownMenu(). Then eg hotkeys don't work.
                dd.Name = tag;
                dd.Tag  = x;
                Submenus.Add(tag, dd);

                if (s != null)                              //attribute dd="". Will be filled later, eg on Opening event.
                {
                    dd.Items.Add(new ToolStripSeparator()); //else no drop arrow and no Opening event
                    return;
                }
#if !LAZY_MENUS
                dd.SuspendLayout();                 //with this don't need lazy menus
                _AddChildItems(x, dd, true);
                dd.ResumeLayout(false);
#else
                //Fill menu items later. This saves ~50 ms of startup time if not using dd.SuspendLayout. With dd.SuspendLayout - just 5 ms.
                //Can do it with Opening event or with timer. With timer easier. With event users cannot use MSAA etc to automate clicking menu items (with timer cannot use it only the first 1-2 seconds).
#if true
                ATimer.After(500, t =>
                {
                    dd.SuspendLayout();
                    _AddChildItems(x, dd, true);
                    dd.ResumeLayout(false);
                });
#else
                dd.Items.Add(new ToolStripSeparator());
                CancelEventHandler eh = null;
                eh = (sender, e) =>
                {
                    dd.Opening -= eh;
                    dd.Items.Clear();
                    _AddChildItems(x, dd, true);
                };
                dd.Opening += eh;
#endif
#endif
            }
        }

        void _SetItemProperties(XElement x, ToolStripItem item, bool isMenu, bool isControl)
        {
            string s, defaultText = null;

            var tt = x.Attr("tt");             //tooltip

            item.ToolTipText = tt ?? (isMenu ? null : (defaultText = _GetDefaultItemText(x)));

            if (!isMenu)
            {
                if (x.HasAttr("hide"))
                {
                    item.Overflow = ToolStripItemOverflow.Always;
                }
                else if (!_inBuildAll)
                {
                    item.Overflow = ToolStripItemOverflow.AsNeeded;
                }
            }
            if (isControl)
            {
                return;
            }

            Image im = null;

            if (x.Attr(out s, "i2"))              //custom image as icon file
            {
                im = AIcon.GetFileIconImage(s);
                if (im == null)
                {
                    AOutput.Write($"Failed to get {(isMenu ? "menu item" : "toolbar button")} {x.Name} icon from file {s}\n\tTo fix this, right-click it and select Properties...");
                }
                //SHOULDDO: async or cache
            }
            if (im == null && x.Attr(out s, "i"))
            {
                im = _callbacks.GetImage(s);                                              //image from resources
            }
            item.Image = im;

            if (x.Attr(out s, "color") && ColorInt.FromString(s, out var color))
            {
                item.ForeColor = (Color)color;
            }
            else if (!_inBuildAll)
            {
                item.ForeColor = Color.FromKnownColor(KnownColor.ControlText);
            }

            bool hasCustomText = x.Attr(out s, "t2");             //custom text

            item.Text = s ?? defaultText ?? _GetDefaultItemText(x);

            if (isMenu)
            {
                var mi = item as ToolStripMenuItem;
                if (!_inBuildAll)
                {
                    mi.ShortcutKeys             = 0;
                    mi.ShortcutKeyDisplayString = null;
                }
                if (x.Attr(out s, "hk"))
                {
                    bool ok = AKeys.More.ParseHotkeyString(s, out var hk);
                    if (ok)
                    {
                        try { mi.ShortcutKeys = hk; } catch { ok = false; }
                    }
                    if (!ok)
                    {
                        ADebug.Print("Invalid hotkey: " + s);
                    }
                }
                if (x.Attr(out string ss, "hkText"))
                {
                    mi.ShortcutKeyDisplayString = (s == null) ? ss : s + ", " + ss;
                }
            }
            else
            {
                var style = item.Image == null ? ToolStripItemDisplayStyle.ImageAndText : (ToolStripItemDisplayStyle)x.Attr("style", 0);
                if (style == 0)
                {
                    style = hasCustomText ? ToolStripItemDisplayStyle.ImageAndText : ToolStripItemDisplayStyle.Image;                            //0 is ToolStripItemDisplayStyle.None
                }
                item.DisplayStyle = style;
            }
        }

        /// <summary>
        /// If x has attribute t, gets its value.
        /// Else gets its name and converts to text, eg "File_OneTwo" to "One Two".
        /// </summary>
        string _GetDefaultItemText(XElement x)
        {
            if (!x.Attr(out string s, "t"))
            {
                string tag = x.Name.LocalName;
                s = tag.Remove(0, tag.LastIndexOf('_') + 1);                 //eg "Edit_Copy" -> "Copy"
                s = s.RegexReplace("(?<=[^A-Z])(?=[A-Z])", " ");             //"OneTwoThree" -> "One Two Three". //speed: don't need to optimize.
            }
            return(s);
        }

        /// <summary>
        /// Merges custom attributes into default menubar or toolbar XML.
        /// Reorders toolbar buttons if need.
        /// </summary>
        /// <param name="xCustom">Root element of customizations file.</param>
        /// <param name="xtsDef">Default menustrip or toolstrip. For custom toolbars the function can replace it.</param>
        /// <param name="name">xtsDef name, just to avoid getting it again.</param>
        /// <param name="isMenu"></param>
        void _MergeCustom(XElement xCustom, ref XElement xtsDef, string name, bool isMenu)
        {
            var xtsCust = xCustom.Element(xtsDef.Name); if (xtsCust == null)

            {
                return;
            }

            if (isMenu)
            {
            }
            else if (name.Starts("Custom"))
            {
                var xc = xCustom.Element(name); if (xc == null)
                {
                    return;
                }
                xc.Remove();
                xtsDef.ReplaceWith(xc);
                xtsDef = xc;
                return;
                //MSDN: "if the new content has no parent, then the objects are simply attached to the XML tree. If the new content already is parented and is part of another XML tree, then the new content is cloned". Tested, it's true.
            }
            else
            {
                //reorder toolbar buttons
                if (xtsCust.Attr(out string s, "order"))
                {
                    xtsDef.Elements("sep").Remove();                     //remove all default <sep/>, because all separators now are in the 'order' attribute
                    var a = s.SegSplit(" ");
                    for (int i = a.Length - 1; i >= 0; i--)
                    {
                        if (a[i] == "sep")
                        {
                            xtsDef.AddFirst(new XElement("sep"));
                        }
                        else
                        {
                            var xb = xtsDef.Element(a[i]); if (xb == null)
                            {
                                continue;
                            }
                            xb.Remove(); xtsDef.AddFirst(xb);
                        }
                    }
                }
            }

            foreach (var xCust in xtsCust.Elements())
            {
                foreach (var xDef in xtsDef.Descendants(xCust.Name))
                {
                    foreach (var att in xCust.Attributes())
                    {
                        xDef.SetAttributeValue(att.Name, att.Value);
                    }
                }
            }
        }

        /// <summary>
        /// Extracts differences between _xmlFileDefault and _xStrips and saves to _xmlFileCustom.
        /// </summary>
        void _DiffCustom()
        {
            var    xStripsDefault = AExtXml.LoadElem(_xmlFileDefault);
            var    xStripsCustom  = new XElement("strips");
            string s;

            //menus
            _DiffDescendants(MenuBar.Tag as XElement, true);

            //standard toolbars
            foreach (var ts in Toolbars.Values)
            {
                if (ts == _tsCustom1 || ts == _tsCustom2)
                {
                    continue;
                }
                _DiffDescendants(ts.Tag as XElement, false);
            }

            void _DiffDescendants(XElement xts, bool isMenu)
            {
                XElement xtsDef = xStripsDefault.Element(xts.Name), xtsCust = null;

                foreach (var x in xts.Descendants())
                {
                    var name = x.Name; if (name == "sep")
                    {
                        continue;
                    }
                    XElement xDef = xtsDef.Desc(name), xCust = null;
                    foreach (var att in x.Attributes())
                    {
                        var aname = att.Name;
                        if (att.Value == xDef.Attr(aname))
                        {
                            continue;
                        }
                        if (xtsCust == null)
                        {
                            xStripsCustom.Add(xtsCust = new XElement(xts.Name));
                        }
                        if (xCust == null)
                        {
                            xtsCust.Add(xCust = new XElement(name));
                        }
                        xCust.SetAttributeValue(aname, att.Value);
                    }
                }
                if (isMenu)
                {
                    return;
                }
                //order
                var s1 = new StringBuilder();
                var s2 = new StringBuilder();

                foreach (var x in xts.Elements())
                {
                    if (s1.Length > 0)
                    {
                        s1.Append(' ');
                    }
                    s1.Append(x.Name);
                }
                foreach (var x in xtsDef.Elements())
                {
                    if (s2.Length > 0)
                    {
                        s2.Append(' ');
                    }
                    s2.Append(x.Name);
                }
                s = s1.ToString();
                if (s != s2.ToString())
                {
                    if (xtsCust == null)
                    {
                        xStripsCustom.Add(xtsCust = new XElement(xts.Name));
                    }
                    xtsCust.SetAttributeValue("order", s);
                }
            }

            //custom toolbars. Temporarily move them from _xStrips to xCustom.
            var xCust1 = _tsCustom1.Tag as XElement;
            var xCust2 = _tsCustom2.Tag as XElement;

            if (xCust1.HasElements)
            {
                xCust1.Remove(); xStripsCustom.Add(xCust1);
            }
            if (xCust2.HasElements)
            {
                xCust2.Remove(); xStripsCustom.Add(xCust2);
            }

            //AOutput.Clear();
            //AOutput.Write(xStripsCustom);
#if true
            //save
            try {
                AFile.CreateDirectoryFor(_xmlFileCustom);
                xStripsCustom.SaveElem(_xmlFileCustom);
            }
            catch (Exception e) {
                AOutput.Write("Failed to save XML file", _xmlFileCustom, e.Message);
            }
#endif

            if (xCust1.HasElements)
            {
                xCust1.Remove(); _xStrips.Add(xCust1);
            }
            if (xCust2.HasElements)
            {
                xCust2.Remove(); _xStrips.Add(xCust2);
            }
        }
示例#13
0
        bool _OnSetCursor(Control c, LPARAM lParam)
        {
            bool R = false, hilite = false, isTooltip = false;

            if ((((uint)lParam) & 0xFFFF) == Api.HTCLIENT && !c.Capture)
            {
                var p = c.MouseClientXY();
                switch (_HitTest(c, p.x, p.y, out var ht))
                {
                case _HitTestResult.Splitter:
                    //info: works better than Cursor=x in OnMouseMove.
                    var cursor = ht.gs.IsVerticalSplit ? Cursors.VSplit : Cursors.HSplit;
                    Api.SetCursor(cursor.Handle);
                    R = true;
                    break;

                case _HitTestResult.Caption:
                    var gt = ht.ParentTab;
                    if (gt != null && ht.gp != gt.ActiveItem)
                    {
                        hilite = true;                                                          //highlight inactive tab button
                    }
                    else if (ht.gp != null && ht.gp.HasToolbar)
                    {
                        hilite = true;                                                            //change toolbar caption color from form background color to panel caption color
                    }
                    if (hilite)
                    {
                        if (_hilitedTabButton != ht.gp)
                        {
                            _UnhiliteTabButton();
                            _hilitedTabButton = ht.gp;
                            _hilitedTabButton.InvalidateCaption();
                        }
                    }
                    //tooltip
                    var tt = ht.gp?.ToolTipText;
                    if (!tt.NE())
                    {
                        isTooltip = true;
                        if (_toolTipTabButton != ht.gp)
                        {
                            int delay = _toolTipTabButton == null ? _toolTip.InitialDelay : _toolTip.ReshowDelay;
                            _HideTooltip();
                            _toolTipTabButton = ht.gp;
                            ATimer.After(delay, _ => {
                                var gp = _toolTipTabButton; if (gp == null)
                                {
                                    return;
                                }
                                var p2 = gp.ParentControl.MouseClientXY();
                                _toolTip.Show(gp.ToolTipText, gp.ParentControl, p2.x, p2.y + 20, _toolTip.AutoPopDelay);
                            });
                        }
                    }
                    break;
                }
            }
            if (!hilite)
            {
                _UnhiliteTabButton();
            }
            if (!isTooltip)
            {
                _HideTooltip();
            }
            return(R);
        }