Changing the icon shown in a taskbar group for a multi window application

寵の児 提交于 2019-12-22 10:12:23

问题


On Windows 7 an application can control how to group their Windows on the taskbar. Windows has some default settings related to the executable, how the shortcut was created, the name of the program, etc. to apply some default grouping. The problem with host based applications like Java, is that the same executable is used by many programs so Windows has some registry settings to set that javaw.exe is a host app. When this happens, applications must configure at runtime how to group Windows and enable pin to taskbar. I am already setting Application User Model IDs in order to group Windows as needed.

The problem that I haven't found solution is that for a multi window application: how to set a stable icon to be used on the taskbar?. The default Windows behavior for an application, say for example with two windows, where each windows has his own icon, the task bar icon shows the icon of the first opened window, if that window is closed it changes to the other one, and the process is repeated every time windows are opened and closed.

There is some API to set the icon when the user pin an application to the taskbar setting System.AppUserModel.RelaunchIconResource window property, but the documentation says that this icon is used when the app is being pinned, so according to that it only is used if the application is running from that pinned applications, leaving the problem open for applications that are not able to be pinned (or that the developer do not want to allow pinning).

There are options like generating a new executable with the icon (launching the JVM from that application), creating a shortcut with the correct AppUserModelID. Those aren't solutions for me because the application is distributed using Java WebStart/JNLP, so the application shortcut is created by Java and the launcher is a marked as a host application (as it should)

the other solution is to set the same icon to each window when running on Windows 7, that icon, with the exception of the taskbar one, is not very prominent on Windows 7 on Aero mode, but with Aero disabled it is, it is the icon used on the Alt+tab switcher without windows previews, something I want to leave looking different for each windows

Note: This is a tagged Java but really is a question for any platform that use a host executable (javaw.exe, python.exe ...)

来源:https://stackoverflow.com/questions/8475336/changing-the-icon-shown-in-a-taskbar-group-for-a-multi-window-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!