我有一张表格
Opacity
小于1.0。我有一个工具提示与表单上的标签关联。当我将鼠标悬停在标签上时,工具提示会出现
在下面
形式而不是
结束
形式。如果不透明度保持默认值1.0,则工具提示将正确显示在表单上。然而,我的身体显然不再是半透明的。;-)
我尝试手动调整工具提示的位置
SetWindowPos()
并使用
CreateWindowEx()
但问题依然存在。这让我怀疑它是一个win32 api问题,而不是运行在win32之上的Windows窗体实现的问题。
为什么工具提示出现在表单下,更重要的是,我如何让它出现在表单上应该出现的位置?
编辑
:这似乎是XP唯一的问题。Vista和Windows7工作正常。我仍然希望找到一个解决方法,让工具提示显示在xp上的表单上方。
下面是一个演示问题的最小程序:
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;
}
}