Why does this tooltip appear *below* a transclucent form?
- by Daniel Stutzbach
I have an form with an Opacity less then 1.0. I have a tooltip associated with a label on the form. When I hover the mouse over the label, the tooltip shows up under the form instead of over the form. If I leave the Opacity at its default value of 1.0, the tooltip correctly appears over the form. However, my form is obviously no longer translucent. ;-)
I'm testing on an XP system with .NET 3.5. If you don't see this problem on your system, let me know what operating system and version of .NET you have.
I have tried manually adjusting the position of the ToolTip with SetWindowPos() and creating a ToolTip "by hand" using CreateWindowEx(), but the problem remains. This makes me suspect its a Win32 API problem, not a problem with the Windows Forms implementation that runs on top of Win32.
Why does the tooltip appear under the form, and, more importantly, how can I get it to appear over the form where it should?
Here is a minimal program to demonstrate the problem:
using System;
using System.Windows.Forms;
public class Form1 : Form
{
private ToolTip toolTip1;
private Label label1;
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
public Form1()
{
toolTip1 = new ToolTip();
label1 = new Label();
label1.Location = new System.Drawing.Point(105, 127);
label1.Text = "Hover over me";
label1.AutoSize = true;
toolTip1.SetToolTip(label1, "This is a moderately long string, "
+ "designed to be very long so that it will also be quite long.");
ClientSize = new System.Drawing.Size(292, 268);
Controls.Add(label1);
Opacity = 0.8;
}
}