我張貼的答案在這個線程採用透明,最大化的模擬屏幕上的任意位置繪製工具提示,包括桌面。也許這將幫助:Creating a tooltip from a system-tray only app
編輯:從鏈接後在複製的代碼便於閱讀:-)
在這裏你去,使用透明,最大化的形式,你BringToFront()
顯示前在ToolTip
Form 1代碼:
using System;
using System.Windows.Forms;
namespace SO_ToolTip
{
public partial class Form1 : Form
{
Random _Random = new Random();
ToolTip _ToolTip = new ToolTip();
public Form1()
{
InitializeComponent();
}
private void timer1_Tick(object sender, EventArgs e)
{
BringToFront();
_ToolTip.Show("Blah blah... Blah blah... Blah blah...", this, _Random.Next(0, Width), _Random.Next(0, Height), 10000);
}
}
}
Form1的設計器代碼:所以你可以看到表格屬性:
namespace SO_ToolTip
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.SuspendLayout();
//
// timer1
//
this.timer1.Enabled = true;
this.timer1.Interval = 1000;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(284, 264);
this.ControlBox = false;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "Form1";
this.Opacity = 0;
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Timer timer1;
}
}
更新:隨着ControlBox = false;
和Opacity = 0;
形式不僅是視覺上透明的,但都難用戶輸入。即使當上面的Form1
點擊它的區域中最頂部的窗口落入下一個窗口/桌面時也是如此。就好像表單不在那裏一樣。顯示工具提示之前的BringToFront()是必需的,否則工具提示可能會在其他窗口下繪製,這不是您想要的。
我認爲這WPF的ToolTip可能是可能的,但它似乎更難。 :-( – itsho 2014-01-07 13:57:10