X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/4ad16c5f92d70b80cf32c2d87bf4b2c8ecfefdbe..74b1f0b45e0f0bc7e25c5f32bb495e3e4bcd3392:/src/msw/taskbar.cpp diff --git a/src/msw/taskbar.cpp b/src/msw/taskbar.cpp index d42b08fe47..a064e5df9e 100644 --- a/src/msw/taskbar.cpp +++ b/src/msw/taskbar.cpp @@ -197,18 +197,25 @@ bool wxTaskBarIcon::SetIcon(const wxIcon& icon, const wxString& tooltip) notifyData.uFlags |= NIF_TIP; if ( !tooltip.empty() ) { - wxStrncpy(notifyData.szTip, tooltip.wx_str(), WXSIZEOF(notifyData.szTip)); + wxStrlcpy(notifyData.szTip, tooltip.wx_str(), WXSIZEOF(notifyData.szTip)); } bool ok = wxShellNotifyIcon(m_iconAdded ? NIM_MODIFY : NIM_ADD, ¬ifyData) != 0; + if ( !ok ) + { + wxLogLastError(wxT("wxShellNotifyIcon(NIM_MODIFY/ADD)")); + } + if ( !m_iconAdded && ok ) m_iconAdded = true; return ok; } +#if wxUSE_TASKBARICON_BALLOONS + bool wxTaskBarIcon::ShowBalloon(const wxString& title, const wxString& text, @@ -216,7 +223,7 @@ wxTaskBarIcon::ShowBalloon(const wxString& title, int flags) { wxCHECK_MSG( m_iconAdded, false, - _T("can't be used before the icon is created") ); + wxT("can't be used before the icon is created") ); const HWND hwnd = GetHwndOf(m_win); @@ -224,20 +231,19 @@ wxTaskBarIcon::ShowBalloon(const wxString& title, // the balloon disappearance NotifyIconData notifyData(hwnd); notifyData.uFlags = 0; -#if (WINVER >= 0x0500) notifyData.uVersion = 3 /* NOTIFYICON_VERSION for Windows XP */; -#endif - - wxShellNotifyIcon(NIM_SETVERSION, ¬ifyData); + if ( !wxShellNotifyIcon(NIM_SETVERSION, ¬ifyData) ) + { + wxLogLastError(wxT("wxShellNotifyIcon(NIM_SETVERSION)")); + } // do show the balloon now notifyData = NotifyIconData(hwnd); notifyData.uFlags |= NIF_INFO; -#if (WINVER >= 0x0500) notifyData.uTimeout = msec; - wxStrncpy(notifyData.szInfo, text.wx_str(), WXSIZEOF(notifyData.szInfo)); - wxStrncpy(notifyData.szInfoTitle, title.wx_str(), + wxStrlcpy(notifyData.szInfo, text.wx_str(), WXSIZEOF(notifyData.szInfo)); + wxStrlcpy(notifyData.szInfoTitle, title.wx_str(), WXSIZEOF(notifyData.szInfoTitle)); if ( flags & wxICON_INFORMATION ) @@ -246,11 +252,18 @@ wxTaskBarIcon::ShowBalloon(const wxString& title, notifyData.dwInfoFlags |= NIIF_WARNING; else if ( flags & wxICON_ERROR ) notifyData.dwInfoFlags |= NIIF_ERROR; -#endif - return wxShellNotifyIcon(NIM_MODIFY, ¬ifyData) != 0; + bool ok = wxShellNotifyIcon(NIM_MODIFY, ¬ifyData) != 0; + if ( !ok ) + { + wxLogLastError(wxT("wxShellNotifyIcon(NIM_MODIFY)")); + } + + return ok; } +#endif // wxUSE_TASKBARICON_BALLOONS + bool wxTaskBarIcon::RemoveIcon() { if (!m_iconAdded) @@ -260,13 +273,19 @@ bool wxTaskBarIcon::RemoveIcon() NotifyIconData notifyData(GetHwndOf(m_win)); - return wxShellNotifyIcon(NIM_DELETE, ¬ifyData) != 0; + bool ok = wxShellNotifyIcon(NIM_DELETE, ¬ifyData) != 0; + if ( !ok ) + { + wxLogLastError(wxT("wxShellNotifyIcon(NIM_DELETE)")); + } + + return ok; } #if wxUSE_MENUS bool wxTaskBarIcon::PopupMenu(wxMenu *menu) { - wxASSERT_MSG( m_win != NULL, _T("taskbar icon not initialized") ); + wxASSERT_MSG( m_win != NULL, wxT("taskbar icon not initialized") ); static bool s_inPopup = false;