代码之家  ›  专栏  ›  技术社区  ›  Daniel Stutzbach Edward Leno

在XP上,如何让工具提示显示在透明窗体的上方?

  •  2
  • Daniel Stutzbach Edward Leno  · 技术社区  · 16 年前

    我有一张表格 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;
        }
    }
    
    2 回复  |  直到 16 年前
        1
  •  1
  •   Mark Byers    16 年前

    为我工作!

    在Windows Vista上使用.NET 3.5。

    在Windows Vista上使用.NET 3.5。

        2
  •  3
  •   Anders    16 年前

    xp以具有z顺序而闻名。 tooltip bugs . 当您在工具提示上使用setwindowpos()时,是否用hwnd_-topmost将其标记为始终在顶部?

    推荐文章