[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Common Tray Message

Posted on 2011-10-09
Medium Priority
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

jkr earned 2000 total points
ID: 36939569
You will  like http://www.codeproject.com/KB/dialog/MessageBalloon.aspx 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


Featured Post


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

834 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