Cra*_*ack 12 .net c# tooltip winforms
我正在寻找一种方法来向.NET ToolTip对象添加一个类似于NotifyIcon的关闭按钮.我正在使用工具提示作为使用Show()方法以编程方式调用的消息气球.这工作正常,但没有onclick事件或关闭工具提示的简单方法.你必须在代码中的其他地方调用Hide()方法,我宁愿让工具提示能够自行关闭.我知道网络周围有几个气球工具提示使用管理和非托管代码来执行Windows API,但我宁愿留在我舒适的.NET世界中.我有一个第三方应用程序调用我的.NET应用程序,它在尝试显示非托管工具提示时崩溃.
您可以尝试通过覆盖现有工具提示窗口并自定义 onDraw 函数来实现自己的工具提示窗口。我从未尝试过添加按钮,但之前曾使用工具提示进行过其他自定义。
1 class MyToolTip : ToolTip
2 {
3 public MyToolTip()
4 {
5 this.OwnerDraw = true;
6 this.Draw += new DrawToolTipEventHandler(OnDraw);
7
8 }
9
10 public MyToolTip(System.ComponentModel.IContainer Cont)
11 {
12 this.OwnerDraw = true;
13 this.Draw += new DrawToolTipEventHandler(OnDraw);
14 }
15
16 private void OnDraw(object sender, DrawToolTipEventArgs e)
17 {
...Code Stuff...
24 }
25 }
Run Code Online (Sandbox Code Playgroud)