Windows 7 で初めてプログラムを実行すると、アイコンが自動的に非表示になります。Windows 7 にデフォルトで常にアイコンを表示させるマニフェスト設定またはオプションはありますか?
3 に答える
少し前の .NET Rocks ポッドキャストで、Microsoft の Kate Gregory が、それは不可能だと言いました。
彼女は次のようなことを言いました:「ユーザーがそれを望むなら(トレイアイコン)彼/彼女はそこに置きます」. この理由は、トレイ領域の混乱を防ぐためです。
If you really want to show your tray-icon, you can popup a balloon with minimal text and just afterwards hide the balloon and it's shadow again by following code-example:
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
if you repeat this (e.g. every 30 seconds), your trayicon will stay there because Explorer.exe thinks, there is a balloon open to display to the user. A few minor issues - such as no right-click directly on icon - are still there.
I really used to show the tray icon for our company-software where the user are not intended to do this manually and for each update. So maybe this will help someone... :)
Otherwise, I totally agree: This should be only in hands of the user, not controlled by the application.
もちろん「不可能」ではありません。ITrayNotify
トレイ アイコンを取得し、それらの可視性を変更するための文書化されていない COM インターフェイスがあり、Explorer 自体によって使用されます。完全な C++ ソースはこちら: http://thread0.me/tag/windows/
もちろん、非公式の API を使用するのは危険であり、Windows 8 ではこの API に重大な変更が加えられています。つまり、XP 用に 2 つの異なる定義 (Win7 と Win8 - Win10) を使用する必要があります。でもねえ、Chrome でさえこのトリックを使用します。失敗を適切に処理するようにしてください。