ToolTip.Show for an inactive window does not work

Why is the tooltip displayed manually with the help ToolTip.Shownot displayed when the window containing the control is inactive?

public class MyControl : Button
{

    private _tip;
    public string ToolTip
    {
        get { return _tip; }
        set { _tip = value; }
    }

    private ToolTip _toolTip = new ToolTip();

    public MyControl()
    {
        _toolTip.UseAnimation = false;
        _toolTip.UseFading = false;
        _toolTip.ShowAlways = true;
    }

    protected override void OnMouseHover(EventArgs e)
    {
        _toolTip.Show(_tip, this, 0, Height);
        base.OnMouseHover(e);
    }

    protected override void OnMouseLeave(EventArgs e)
    {
        _toolTip.Hide(this);
        base.OnMouseLeave(e);
    }
}

I went on ToolTip.Showbecause I have to have a tooltip on the screen for an unlimited time, which is impossible when using the usual one ToolTip. I also like the idea of ​​having tooltip text as part of the management itself. But unfortunately, when showing a tooltip for an inactive window (despite ShowAlways = true), it just doesn't work.

The event is OnMouseHowerhighlighted, but _toolTip.Showdoes nothing .. if the window is not activated, then everything works.

Bounty

( , , IContainer).

+4
1

, , , , :

using System.Reflection;

public class MyControl : Button {
  private ToolTip toolTip = new ToolTip() {
    UseAnimation = false,
    UseFading = false
  };

  public string ToolTip { get; set; }

  protected override void OnMouseHover(EventArgs e) {
    base.OnMouseHover(e);
    Point mouse = MousePosition;
    mouse.Offset(10, 10);
    MethodInfo m = toolTip.GetType().GetMethod("SetTool",
                           BindingFlags.Instance | BindingFlags.NonPublic);
    m.Invoke(toolTip, new object[] { this, this.ToolTip, 2, mouse });
  }

  protected override void OnMouseLeave(EventArgs e) {
    base.OnMouseLeave(e);
    toolTip.Hide(this);
  }
}

, , - .

+4

All Articles