Place an application's icon into system tray
Asked Answered
A

1

3

I'm making a desktop mascot with unity, and I do not want to see the icon appearing on the task bar, I want the icon in the system tray. Is there a way to do this?

enter image description here

PS: This is NOT a windows form (it's a game), so I believe Form.ShowInTaskbar will not work.

Autopsy answered 27/8, 2018 at 0:59 Comment(3)
When you start looking in Microsoft's documentation for info on how to do this, be aware that the formal name for that is the Notification Area (though some Microsoft docs do use Tray, much to the consternation of @RaymondChen). blogs.msdn.microsoft.com/oldnewthing/20030910-00/?p=42583Temple
I think the easiest way to do this is to have two applications, one for the Unity app that doesn't show up in the task bar at all, and one Windows program that sits in the tray, you can use System.Process methods to control it or tcp/udp/named pipes.Anamorphism
@RonBeyer The latter part seems doable, but how can I make the unity app does not show up in the taskbar?Autopsy
T
2

I've never programmed in Unity, but I'm assuming you are working in a Windows window. If you make the top level window for the application not appear in the main area of the Taskbar, make the window a "Tool Window" (by setting the WS_EX_TOOLWINDOW extended style on the window), then the window/app will not show up on the taskbar.

I'll leave it to someone how knows enough Unity to tell you how to set that style. Here's a reference to start with (on the Windows side, not the Unity side): Managing Taskbar Buttons

Temple answered 27/8, 2018 at 4:37 Comment(3)
This is a good way to make it disappear from the taskbar, but since my mascot must have a transparent and borderless window, so this is not so suitable for me. Anyway, thank you!Autopsy
Problem solved, thank you! Turns out I just need to set my window as tool window and then remove the border and make it transparent.Autopsy
I was surprised it was an issue. I've set TOOL_WINDOW on all sorts of windows before, and it's always Just Worked. Glad I could helpTemple

© 2022 - 2024 — McMap. All rights reserved.