简体   繁体   English

当用户打开应用程序两次时,如何避免任务栏按钮被合并到我的应用程序中?

[英]How can I avoid that the taskbar buttons get combined for my application when the user opens it twice?

In more recent versions of Windows the taskbar will combine two buttons together when I open the same application twice. 在Windows的最新版本中,当我两次打开同一应用程序时,任务栏会将两个按钮组合在一起。 What can I do to avoid that (not counting changing the Windows settings, because I want it for my application only, not all applications). 我该怎么做才能避免这种情况(不包括更改Windows设置,因为我只希望将其用于我的应用程序,而不是所有应用程序)。

Raymond Chen has detailed how to do this a while ago on his blog: How do I customize how my application windows are grouped in the Taskbar? Raymond Chen不久前在他的博客上详细介绍了如何执行此操作: 如何自定义应用程序窗口在任务栏中的分组方式? :

All the information in this article came from the article Application User Model IDs (AppUserModelIDs) in MSDN. 本文中的所有信息均来自MSDN中的文章应用程序用户模型ID(AppUserModelIDs)

Okay, so suppose your application is really a runtime for other applications. 好的,假设您的应用程序确实是其他应用程序的运行时。 What you need to do is assign a different AppID to each of the applications you are hosting. 您需要做的是为您托管的每个应用程序分配一个不同的AppID。 The mechanism for this is up to you. 机制由您决定。 Your applications might explicitly provide a unique ID, or you may be able to infer one. 您的应用程序可以显式提供唯一的ID,或者您可以推断一个。 For example, if you are Internet Explorer and your "applications" are pinned Web sites, you can use the URL of the site being pinned as the unique ID. 例如,如果您是Internet Explorer,并且“应用程序”是固定的网站,则可以使用被固定的站点的URL作为唯一ID。

You then get to take your unique IDs and create AppIDs for them. 然后,您将获取自己的唯一ID并为其创建AppID。 The format of an AppID is AppID格式

 CompanyName.ProductName.SubProduct.VersionInformation 

where the SubProduct is optional, and the VersionInformation is present only if you want different versions of your app to be treated as distinct. 其中SubProduct是可选的,仅当您希望将不同版本的应用程序视为不同版本时,才显示VersionInformation。 (If you want an upgraded version to be a replacement for the old version, then omit the VersionInformation so that the old and new versions use the same AppID.) (如果您希望升级后的版本替代旧版本,请省略VersionInformation,以便新旧版本使用相同的AppID。)

You then assign this AppID to every window associated with the "application". 然后,您将此AppID分配给与“应用程序”关联的每个窗口。 You can do this for an entire process by calling SetCurrentProcessExplicitAppUserModelID , or you can do it on a window-by-window basis by setting the PKEY_AppUserModel_ID property. 您可以通过调用SetCurrentProcessExplicitAppUserModelID在整个过程中执行此操作,也可以通过设置PKEY_AppUserModel_ID属性在PKEY_AppUserModel_ID 窗口中执行PKEY_AppUserModel_ID

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 收件人打开我的邮件时如何获取收件人的 IP 地址和位置? - How can I get recipient ip address and location when Recipient opens my mail? 当我运行此应用程序时,如何使主窗体位于任务栏的右下角? - How can i make that when i run this application the main form will be in the taskbar bottom right corner? 如何为应用程序创建/添加动画图标/图像以在任务栏中显示? - How can i create/add animated icon/image for my application to be show in the taskbar? 如何在C#应用程序中显示任务栏通知? - How do I show a taskbar notification in my C# application? 如何将我的应用程序与 Windows 7 任务栏上的固定程序相关联? - How do I associate my application with a pinned program on the Windows 7 taskbar? 如何在 WPF 应用程序中获取 Windows 任务栏高度? - How do I get windows taskbar height in WPF application? 我想在任务栏上单击窗体并将其打开时运行一个函数 - I want to run a function when ever the form is clicked on taskbar and it opens 当我在DataGridView中选择行时,如何获取单选按钮以反映数据库中的内容 - How can i get the Radio buttons to reflect what is in the database when i select rows in my DataGridView AppSettings中的更改需要重启我的应用程序如何避免? - Change in AppSettings needs restart my Application how can I avoid? 如何禁用或自定义当用户将鼠标悬停在任务栏上的应用程序图标上时显示的图像预览? - How can I disable or customize the image preview, which displays when a user hovers over an app's icon on the taskbar?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM