Common Tray Message

Posted on 2011-10-09
Last Modified: 2012-06-27
is it possible to send a tray message, like an update information, to the system try by windows api?
I see some software products use a total overhead with codejock or similar. But others seems to use a simple message with a common windows style, like the good old bubble tooltip on XP.

So if you have  sample code or a link to a good tuturial, you are my hero.

Question by:Ocrana
    1 Comment
    LVL 86

    Accepted Solution

    You will  like for it's sheer simplicity:
    struct MessageBalloon : public NOTIFYICONDATA
        MessageBalloon(LPCTSTR _szInfo = _T("Prompt"), LPCTSTR _szInfoTitle = 0, 
            LPCTSTR _szTip = 0, HICON _hIcon = 0)
            static struct wnd_holder{
                HWND hwnd_;
                wnd_holder(){hwnd_ = CreateWindowW(L"STATIC", 0, 0, 0, 0, 0, 0, 0, 
                    0, 0, 0);}
            } wh;
            memset(this, 0, sizeof(*this));
            cbSize = sizeof(*this);
            hWnd = wh.hwnd_;
            hIcon = _hIcon ? _hIcon : 
            if (! hIcon) hIcon = ::LoadIcon(NULL, IDI_INFORMATION);
            uFlags = NIF_INFO | NIF_TIP | NIF_ICON; 
            dwInfoFlags = NIIF_INFO;
            _tcscpy(szInfo, _szInfo);
            if (! _szInfoTitle) LoadString(::GetModuleHandle(NULL), 
                57344/*AFX_IDS_APP_TITLE*/, szInfoTitle, sizeof(szInfoTitle));
            else _tcscpy(szInfoTitle, _szInfoTitle);
            _tcscpy(szTip, _szTip ? _szTip : szInfoTitle);
            Shell_NotifyIcon(NIM_ADD, this);
        ~MessageBalloon(){Shell_NotifyIcon(NIM_DELETE, this);}

    Open in new window


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (…
    A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
    The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
    The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now