ToolTip still visible even if form is minimized or in background

526 views Asked by At

In a WinForms Form I show a tooltip if a certain action has finished. I show it this way:

this.myToolTip.Show(message, this, location, duration);

The problem now is that the tooltip is still visible even if the form is going to be minimized or another form (different application) becomes active. Is there any solution for this problem?

2

There are 2 answers

0
OnoSendai On

You may try to .Hide the tooltip when the form loses focus (deactivate). Like this:

    private void Form1_Deactivate(object sender, EventArgs e)
    {
        this.myToolTip.Hide(myTargetControl);
    }
0
Sinatr On

If you show Tooltip manually, then you have to hide it manually as well. The only question is by which event you show it (because perhaps you want to re-show it). Typically all event tooltips are shown for tray icons, for this there is a dedicated component - NotifyIcon, which comes with tooltip.

Otherwise, you are more likely showing tooltip when mouseovering something (OnMouseEnter, or better OnMouseHover), then just hide it in the OnMouseLeave.