开发者

Change the ApplicationID of a running process from c#

In Windows 7 we have the concept of ApplicationID, which allows (among other things) to group several icons in the task bar. How can I change the ApplicationID of a running process fro开发者_如何学Pythonm c#? I'm trying to make my WinForm app's icon group with another application. I've tried using Windows API Code Pack Library, sticking the following code in my Load event... but it didn't work. Suggestions?

TaskbarManager.Instance.ApplicationId = "MyAppID";    
Process[] p = Process.GetProcessesByName("OtherProcess");
TaskbarManager.Instance.SetApplicationIdForSpecificWindow(p[0].MainWindowHandle, "MyAppID");


I repro this. I think the SDK docs are wrong and the XML docs for the SetApplicationIdForSpecificWindow() method are correct:

AppId specifies a unique Application User Model ID (AppID) for the application or individual top-level window whose taskbar button will hold the custom JumpList built through the methods class.

By setting an appId for a specific window, the window will NOT be grouped with it's parent window/application. Instead it will have it's own taskbar button.

I emphasized NOT.


A (somewhat) obvious solution is to set both of the windows' Application IDs you want grouped together to the same ID.

Example:

TaskbarManager.Instance.SetApplicationIdForSpecificWindow(win1.MainWindowHandle, "W00T");
TaskbarManager.Instance.SetApplicationIdForSpecificWindow(win2.MainWindowHandle, "W00T");

Aaaaand both the windows will be grouped together.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜