用 GIF 替换工具提示文本 [英] Replacing ToolTip Text with a GIF

查看:25
本文介绍了用 GIF 替换工具提示文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在重新设计一个较旧的应用程序,使其更加用户友好.我想做的一个补充是,当鼠标悬停在特定按钮上时,一个 ~(200, 200) 演示 GIF 出现在光标的右下角(类似于工具提示的功能).

I'm working on redesigning an older application to make it more user-friendly. One addition I would like to make is, when hovering over a specific button, a ~(200, 200) demonstrative GIF appears to the bottom right of the cursor (similar to the functionality of a ToolTip).

我查看了 ToolTip 类的修改,这似乎是多余的.上面提到的将是理想的,尽管我正在考虑在悬停 2 秒左右后出现的静态图像框.

I looked into the modification of the ToolTip class, which seems excessive. The above mentioned would be ideal, though I am considering a static imageBox that appears after a hovering for 2 or so seconds.

有人能引导我走向正确的方向吗?

Could anyone lead me in the right direction?

推荐答案

看看这篇文章,它在工具提示中详细说明了图像的步骤 https://www.codeproject.com/Articles/42050/ToolTip-With-Image-C

Take a look at this article, it details out the steps of the image in a tooltip https://www.codeproject.com/Articles/42050/ToolTip-With-Image-C

特别是这个方法:

void CustomizedToolTip_Draw(object sender, DrawToolTipEventArgs e)
{
        e.Graphics.CompositingQuality = CompositingQuality.HighQuality;
        myToolTipRectangle.Size = e.Bounds.Size;
        e.Graphics.FillRectangle(myBorderBrush, myToolTipRectangle);
        myImageRectangle = Rectangle.Inflate(myToolTipRectangle, 
                -BORDER_THICKNESS, -BORDER_THICKNESS);
        e.Graphics.FillRectangle(myBackColorBrush, myImageRectangle);
        Control parent = e.AssociatedControl;
        Image toolTipImage = parent.Tag as Image; 
        if (toolTipImage != null)
        {
            myImageRectangle.Width = myInternalImageWidth;
            myTextRectangle = new Rectangle(myImageRectangle.Right, myImageRectangle.Top,
            (myToolTipRectangle.Width - myImageRectangle.Right - BORDER_THICKNESS), 
                        myImageRectangle.Height);
            myTextRectangle.Location = 
        new Point(myImageRectangle.Right, myImageRectangle.Top);
            e.Graphics.FillRectangle(myBackColorBrush, myTextRectangle);
            e.Graphics.DrawImage(toolTipImage, myImageRectangle);
            e.Graphics.DrawString(e.ToolTipText, myFont, 
            myTextBrush, myTextRectangle, myTextFormat);
        }
        else
        {
            e.Graphics.DrawString(e.ToolTipText, myFont, 
            myTextBrush, myImageRectangle, myTextFormat);
        }
}

这篇关于用 GIF 替换工具提示文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆