Friday, August 26, 2016

ITaskbarList3 interface using plain Windows API

The ITaskbarList3 interface can be used by application (from Windows 7 onwards) to perform following actions:
  • Showing the progress of an operation in the taskbar
  • Showing an overlay icon over the taskbar item
  • Add a tooltip to the taskbar thumbnai
  • Adding a toolbar to the taskbar of the application
Even the interface functions are descibed at MSDN (see link below), getting it to work might not be that easy. Therefore here are the steps to make use of the ITaskbarList3 from a C/C++ application using plain Windows API:
  1. Include Shobjidl.h
  2. Initialize the COM library by calling CoInitialize() or CoInitializeEx()
  3. After your main window is created (e.g. after CreateWindowEx() call), define the message "TaskbarButtonCreated" using RegisterWindowMessage():
    UINT taskbarButtonCreatedMessageId = RegisterWindowMessage ( "TaskbarButtonCreated" );
    Store the returned message ID for later use.
  4. To ensure that your main window receives this message, enhance the message reception filter privileges:
    ChangeWindowMessageFilterEx(mainWindow, taskbarButtonCreatedMessageId, MSGFLT_ALLOW, NULL);
  5. Afterwards the message with ID returned by RegisterWindowMessage() is sent to the window procedure of your main window. If it's received, create an instance of the ITaskbarList3 interface using CoCreateInstance():
    ITaskbarList3* pTaskbar = NULL;
    LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
      if (uMsg == taskbarButtonCreatedMessageId)
        HRESULT hr = CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, IID_ITaskbarList3, reinterpret_cast(&pTaskbar));
  6. From now on, you can call the ITaskbarList3 functions using variable pTaskbar, e.g. pTaskbar->SetProgressState(hwnd, TBPF_ERROR);
  7. Before quitting the application, remember to release the interface and close the COM library:
I hope those steps help you in order to use this interface. For an working example with source code, see

ITaskbarList3 interface at MSDN:

Regards, Sunshine2k

No comments: