Click here to Skip to main content
Click here to Skip to main content

Badges for Windows 7

, 9 Mar 2012 CPOL
Rate this:
Please Sign up or sign in to vote.
Short description how to create a sexy badge for windows 7 taskbar


How to use ITaskbarList3 in C++ to add overlay icon into taskbar. 

Using the code

Before using ITaskbarList3, we must receive TaskbarButtonCreated message from system. First we must register this message.

s_uTBBC = RegisterWindowMessage(L"TaskbarButtonCreated");

In our message loop we can catch this message and call our function:

if( message == s_uTBBC ) {
    onTaskbarButtonCreated(wParam, lParam);

Create instance of ITaskbarList3 and set the overlay icon.

static LRESULT onTaskbarButtonCreated(WPARAM wParam, LPARAM lParam) {

    HRESULT result = CoCreateInstance(CLSID_TaskbarList, NULL, 
                        CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&m_pTaskBarlist));

    if (SUCCEEDED(result)) { 
        result = m_pTaskBarlist->HrInit(); 
        if (SUCCEEDED(result)) {

            HICON icon = createBadgeIcon(_T("78"));
            m_pTaskBarlist->SetOverlayIcon(m_hWnd, icon, _T("Status"));


    return 0;

I use GDI+ for creating badge icon. For create cool small ellipse I use circle (letter 'l') from Wingdings font Smile | :)

static HICON createBadgeIcon(const TCHAR *value) {

    Color bagdeColor = Color(233, 0, 0);
    Color textColor = Color(244, 244, 244);
    Bitmap *bitmap = new Bitmap(24, 24, PixelFormat32bppARGB);
    m_Graphics = Graphics::FromImage(bitmap);
    StringFormat format(StringFormatFlagsNoWrap);
    m_Graphics->DrawString(_T("l"), 1, 
                            new Font(_T("Wingdings"), 24), 
                            RectF(1, 2, 24, 24), 
                            new SolidBrush(bagdeColor));
    m_Graphics->DrawString(value, wcslen(value), 
                            new Font(_T("Calibri"), 8), 
                            RectF(1, 2, 24, 20), 
                            &format, new SolidBrush(textColor));
    HICON icon;
    // Cleanup
    delete bitmap;
    return icon;


Version 1.0.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

No Biography provided

Comments and Discussions

-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150327.1 | Last Updated 9 Mar 2012
Article Copyright 2012 by Grigory Avdyushin
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid