caesay caesay - 2 months ago 43
C# Question

control windows 7 taskbar grouping for my application

My program needs to open a series of information windows when requested by a user, and would like to implement some kind of custom grouping on the windows 7 taskbar.

Desired functionality: All of my information windows should be grouped together (if grouping is enabled on the users system, that is) but my main window should NOT be grouped with the information windows.

I can not spawn a new process for my information windows.

My thought process is that there could be a way to modify the window handle of the information window somehow to get the taskbar to group it separately but I honestly don't even know where to start with this.

EDIT

Ive found some new information. I may be able to do something with

SHGetPropertyStoreForWindow
as stated here: http://msdn.microsoft.com/en-us/library/windows/desktop/dd378459(v=vs.85).aspx#where


...As a property of any of the application's running windows. This can be set in one of two ways:
If different windows owned by one process require different AppUserModelIDs to control taskbar grouping, use SHGetPropertyStoreForWindow to retrieve the window's property store and set the AppUserModelID as a window property.

Answer Source

I solved it by using the Windows API Code Pack for .NET and the following code:

TaskbarManager.Instance.SetApplicationIdForSpecificWindow(window, guid);

Window assigned with the same id will be grouped together - windows with a unique id will have a separate taskbar icon.