From d3f1209867593a3287a626110c04dd3234c1dcda Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 1 Dec 2007 22:48:06 +0000 Subject: [PATCH 1/1] added wxEVT_TASKBAR_BALLOON_TIMEOUT/CLICK which will be used by the wxMSW wxNotificationMessage implementation git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@50408 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/taskbar.h | 9 +++++++++ src/common/taskbarcmn.cpp | 2 ++ src/msw/taskbar.cpp | 32 ++++++++++++++++++++++++-------- 3 files changed, 35 insertions(+), 8 deletions(-) diff --git a/include/wx/taskbar.h b/include/wx/taskbar.h index 37af90055a..343aa28766 100644 --- a/include/wx/taskbar.h +++ b/include/wx/taskbar.h @@ -96,6 +96,8 @@ BEGIN_DECLARE_EVENT_TYPES() DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV,wxEVT_TASKBAR_RIGHT_UP,1554) DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV,wxEVT_TASKBAR_LEFT_DCLICK,1555) DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV,wxEVT_TASKBAR_RIGHT_DCLICK,1556) + DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV,wxEVT_TASKBAR_BALLOON_TIMEOUT,1557) + DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV,wxEVT_TASKBAR_BALLOON_CLICK,1558) END_DECLARE_EVENT_TYPES() #define wxTaskBarIconEventHandler(func) \ @@ -122,6 +124,13 @@ END_DECLARE_EVENT_TYPES() #endif #define EVT_TASKBAR_CLICK(fn) wx__DECLARE_TASKBAREVT(CLICK, fn) +// these events are currently generated only under wxMSW and only after (MSW- +// specific) ShowBalloon() had been called, don't use them in portable code +#define EVT_TASKBAR_BALLOON_TIMEOUT(fn) \ + wx__DECLARE_TASKBAREVT(BALLOON_TIMEOUT, fn) +#define EVT_TASKBAR_BALLOON_CLICK(fn) \ + wx__DECLARE_TASKBAREVT(BALLOON_CLICK, fn) + #endif // wxUSE_TASKBARICON #endif // _WX_TASKBAR_H_BASE_ diff --git a/src/common/taskbarcmn.cpp b/src/common/taskbarcmn.cpp index 540dddaad9..5373d527c7 100644 --- a/src/common/taskbarcmn.cpp +++ b/src/common/taskbarcmn.cpp @@ -38,6 +38,8 @@ DEFINE_EVENT_TYPE( wxEVT_TASKBAR_RIGHT_DOWN ) DEFINE_EVENT_TYPE( wxEVT_TASKBAR_RIGHT_UP ) DEFINE_EVENT_TYPE( wxEVT_TASKBAR_LEFT_DCLICK ) DEFINE_EVENT_TYPE( wxEVT_TASKBAR_RIGHT_DCLICK ) +DEFINE_EVENT_TYPE( wxEVT_TASKBAR_BALLOON_TIMEOUT ) +DEFINE_EVENT_TYPE( wxEVT_TASKBAR_BALLOON_CLICK ) BEGIN_EVENT_TABLE(wxTaskBarIconBase, wxEvtHandler) diff --git a/src/msw/taskbar.cpp b/src/msw/taskbar.cpp index be935781d7..0736768648 100644 --- a/src/msw/taskbar.cpp +++ b/src/msw/taskbar.cpp @@ -198,7 +198,19 @@ wxTaskBarIcon::ShowBalloon(const wxString& title, wxCHECK_MSG( m_iconAdded, false, _T("can't be used before the icon is created") ); - NotifyIconData notifyData(GetHwndOf(m_win)); + const HWND hwnd = GetHwndOf(m_win); + + // we need to enable version 5.0 behaviour to receive notifications about + // the balloon disappearance + NotifyIconData notifyData(hwnd); + notifyData.uFlags = 0; + notifyData.uVersion = 3 /* NOTIFYICON_VERSION for Windows XP */; + + wxShellNotifyIcon(NIM_SETVERSION, ¬ifyData); + + + // do show the balloon now + notifyData = NotifyIconData(hwnd); notifyData.uFlags |= NIF_INFO; notifyData.uTimeout = msec; wxStrncpy(notifyData.szInfo, text.wx_str(), WXSIZEOF(notifyData.szInfo)); @@ -289,9 +301,7 @@ long wxTaskBarIcon::WindowProc(unsigned int msg, unsigned int WXUNUSED(wParam), long lParam) { - wxEventType eventType = 0; - - if (msg == gs_msgRestartTaskbar) // does the icon need to be redrawn? + if ( msg == gs_msgRestartTaskbar ) // does the icon need to be redrawn? { m_iconAdded = false; SetIcon(m_icon, m_strTooltip); @@ -299,9 +309,10 @@ long wxTaskBarIcon::WindowProc(unsigned int msg, } // this function should only be called for gs_msg(Restart)Taskbar messages - wxASSERT(msg == gs_msgTaskbar); + wxASSERT( msg == gs_msgTaskbar ); - switch (lParam) + wxEventType eventType = 0; + switch ( lParam ) { case WM_LBUTTONDOWN: eventType = wxEVT_TASKBAR_LEFT_DOWN; @@ -331,11 +342,16 @@ long wxTaskBarIcon::WindowProc(unsigned int msg, eventType = wxEVT_TASKBAR_MOVE; break; - default: + case NIN_BALLOONTIMEOUT: + eventType = wxEVT_TASKBAR_BALLOON_TIMEOUT; + break; + + case NIN_BALLOONUSERCLICK: + eventType = wxEVT_TASKBAR_BALLOON_CLICK; break; } - if (eventType) + if ( eventType ) { wxTaskBarIconEvent event(eventType, this); -- 2.45.2