如果在Windows 7中首次运行程序,则会自动隐藏图标。是否有清单设置或选项可以强制Windows 7始终默认显示图标?
在不久前的.NET Rocks播客中,来自Microsoft的Kate Gregory说过这样一句话:“这是不可能的。”
她的意思是:“如果用户想要托盘图标,他/她会把它放到那里。”这么做的原因是为了避免托盘区域混乱。
如果你真的想显示托盘图标,可以使用以下代码示例弹出一个最小化的文本气泡,然后立即隐藏气泡及其阴影:
trayIcon.ShowBalloonTip(30000, "", ".", ToolTipIcon.None)
Dim balloonHandle As IntPtr = GetBalloonHwnd(balloonText) ' mainly: FindWindow("tooltips_class32", Nothing)
If (balloonHandle <> IntPtr.Zero) Then
Dim sysShadowClassHwnd As IntPtr = FindWindow("SysShadow", Nothing)
' will hide balloon and leaving a small shadow artifact - just for this balloon
PostMessage(balloonHandle, WM_SETREDRAW, IntPtr.Zero, IntPtr.Zero)
SetWindowPos(balloonHandle, IntPtr.Zero, 0, 0, 0, 0, SWP_HIDEWINDOW)
If (sysShadowClassHwnd <> IntPtr.Zero) Then
' this will remove the small shadow artifact
PostMessage(sysShadowClassHwnd, WM_CLOSE, IntPtr.Zero, IntPtr.Zero)
End If
End If