Search code examples
c++windowsqttaskbar

Ungrouping Separate Processes From The Taskbar


I'm writing an application using C++ and Qt which the user can run multiple instances of on the same machine. Each instance of the application has two to three windows associated with them. At the moment, all instances of the application and their windows are grouped together in the taskbar (top image). I want each process to have its own group in the taskbar (bottom image). How can this be achieved?

enter image description here


Solution

  • You can set a different application ID for certain of the windows, or certain of the processes. This is what Windows uses to determine whether to group the icons or not.

    Please see this article: http://msdn.microsoft.com/en-us/magazine/dd942846.aspx


    Pertinent quote:

    Setting the application ID for a process involves a call to the SetCurrentProcessExplicitAppUserModelID Win32 function from shell32.dll. Setting the application ID for a window requires calling the SHGetPropertyStoreForWindow function and then manipulating the returned IPropertyStore object. The following example shows you how to do this:

    PROPVARIANT pv; 
    InitPropVariantFromString(L"MyAppID", &pv);
    IPropertyStore* pps;
    VERIFY(SHGetPropertyStoreForWindow(hwnd, IID_PPV_ARGS(&pps))); 
    VERIFY(pps->SetValue(PKEY_AppUserModel_ID, pv)); 
    VERIFY(pps->Commit());