views:

762

answers:

1

I have some code that pops up a balloon tip. It works on Vista but not on Windows XP. This is the code so far. It works on Vista but not on XP. I can't understand why. This version does not load the icon so it will show up blank.

memset(&m_notifyData, 0, sizeof(NOTIFYICONDATA));
m_notifyData.cbSize = sizeof(NOTIFYICONDATA);
m_notifyData.uFlags = NIF_INFO | NIF_MESSAGE;
m_notifyData.hWnd = (HWND) m_preference_window->GetHWND();
m_notifyData.uID = 99;
m_notifyData.uTimeout = timeout;
m_notifyData.dwInfoFlags = NIIF_NOSOUND | NIIF_INFO;

wxStrncpy(m_notifyData.szInfo, message.c_str(), WXSIZEOF(m_notifyData.szInfo));
wxStrncpy(m_notifyData.szInfoTitle, title.c_str(),WXSIZEOF(m_notifyData.szInfoTitle));

Shell_NotifyIcon(NIM_ADD, &m_notifyData);

wxLogMessage("Balloon timeout is %i", timeout);
m_timer_balloon->Start(timeout, true);

when the time runs, this gets executed:

Shell_NotifyIcon(NIM_DELETE, &m_notifyData);

Any ideas why XP doesn't show the message?

+7  A: 
m_notifyData.cbSize = sizeof(NOTIFYICONDATA);

Should be

m_notifyData.cbSize = NOTIFYICONDATA_V2_SIZE

Vista added several members on top of what XP provided. Size is used to indicate what version of the struct you are passing. XP is rejecting it, since the size is unrecognized.

Michael
Woow! I probably spent 5 hours trying nearly everything on this one. Thanks, thanks, thanks. Works perfectly.
max
@Michael nice catch!
Martlark
awesome, worked like a charm for me!
evargas