wxTaskBarIcon with Balloon tooltips!
The wxWidgets toolkit does not (always) custom draw the elements. It simply wraps the native components making it a familiar environment no matter where you develop your code. Windows, Unix, Mac. The downside only parts that can be shared (like the set of components all OS'es have in common) are limited. Some people would however like to use Windows only things like the balloon tooltips, so they are kind of added.
I do agree there needs to be a better distinquishing between Windows/Mac/Linux only components, and the set all OS'es share, and it might be confusing.
- Jorgen
I do agree there needs to be a better distinquishing between Windows/Mac/Linux only components, and the set all OS'es share, and it might be confusing.
- Jorgen
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb
-
- Part Of The Furniture
- Posts: 1511
- Joined: Sun Jun 19, 2005 11:37 am
- Location: Singapore
- Contact:
OK guys this is the latest patch. This version allows for event handling to be done (took me half a day to solve the mystery of the undefined symbol )EVT_TASKBAR_BALLOON_SHOW will be triggered when the ballon is shown (ballons take turns to be shown)
EVT_TASKBAR_BALLOON_HIDE will be triggered when the balloon is deleted by the program. It isnt sent when the user dismisses the balloon
EVT_TASKBAR_BALLOON_CLICK will be triggered when the user clicks on the balloon
Code: Select all
Index: include/wx/taskbar.h
===================================================================
RCS file: /pack/cvsroots/wxwindows/wxWindows/include/wx/taskbar.h,v
retrieving revision 1.26
diff -u -r1.26 taskbar.h
--- include/wx/taskbar.h 2005/05/04 18:52:03 1.26
+++ include/wx/taskbar.h 2005/08/03 03:42:59
@@ -18,6 +18,13 @@
#include "wx/event.h"
+//Balloon Tooltips messages sent by the shell for MSW
+#ifndef NIN_BALLOONSHOW
+ #define NIN_BALLOONSHOW 1026
+ #define NIN_BALLOONHIDE 1028
+ #define NIN_BALLOONUSERCLICK 1029
+#endif
+
class WXDLLIMPEXP_ADV wxTaskBarIconEvent;
// ----------------------------------------------------------------------------
@@ -93,6 +100,9 @@
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_SHOW,1557)
+ DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV,wxEVT_TASKBAR_BALLOON_HIDE,1558)
+ DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV,wxEVT_TASKBAR_BALLOON_CLICK,1559)
END_DECLARE_EVENT_TYPES()
#define wxTaskBarIconEventHandler(func) \
@@ -108,6 +118,11 @@
#define EVT_TASKBAR_RIGHT_UP(fn) wx__DECLARE_TASKBAREVT(RIGHT_UP, fn)
#define EVT_TASKBAR_LEFT_DCLICK(fn) wx__DECLARE_TASKBAREVT(LEFT_DCLICK, fn)
#define EVT_TASKBAR_RIGHT_DCLICK(fn) wx__DECLARE_TASKBAREVT(RIGHT_DCLICK, fn)
+
+//MSW only events
+#define EVT_TASKBAR_BALLOON_SHOW(fn) wx__DECLARE_TASKBAREVT(BALLOON_SHOW, fn)
+#define EVT_TASKBAR_BALLOON_HIDE(fn) wx__DECLARE_TASKBAREVT(BALLOON_HIDE, fn)
+#define EVT_TASKBAR_BALLOON_CLICK(fn) wx__DECLARE_TASKBAREVT(BALLOON_CLICK, fn)
#endif
// wxHAS_TASK_BAR_ICON
Index: include/wx/msw/taskbar.h
===================================================================
RCS file: /pack/cvsroots/wxwindows/wxWindows/include/wx/msw/taskbar.h,v
retrieving revision 1.24
diff -u -r1.24 taskbar.h
--- include/wx/msw/taskbar.h 2004/09/07 06:00:52 1.24
+++ include/wx/msw/taskbar.h 2005/08/03 04:56:17
@@ -17,6 +17,7 @@
#pragma interface "taskbar.h"
#endif
+#include <shellapi.h>
#include "wx/icon.h"
// private helper class:
@@ -37,6 +38,7 @@
bool SetIcon(const wxIcon& icon, const wxString& tooltip = wxEmptyString);
bool RemoveIcon(void);
bool PopupMenu(wxMenu *menu); //, int x, int y);
+ bool ShowBalloon(wxString title, wxString message, unsigned int timeout = 10000, int icon = NIIF_INFO);
#if WXWIN_COMPATIBILITY_2_4
wxDEPRECATED( bool IsOK() const );
Index: src/common/taskbarcmn.cpp
===================================================================
RCS file: /pack/cvsroots/wxwindows/wxWindows/src/common/taskbarcmn.cpp,v
retrieving revision 1.10
diff -u -r1.10 taskbarcmn.cpp
--- src/common/taskbarcmn.cpp 2004/09/23 18:20:54 1.10
+++ src/common/taskbarcmn.cpp 2005/08/03 03:57:13
@@ -35,6 +35,9 @@
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_CLICK )
+DEFINE_EVENT_TYPE( wxEVT_TASKBAR_BALLOON_HIDE )
+DEFINE_EVENT_TYPE( wxEVT_TASKBAR_BALLOON_SHOW )
BEGIN_EVENT_TABLE(wxTaskBarIconBase, wxEvtHandler)
Index: src/msw/taskbar.cpp
===================================================================
RCS file: /pack/cvsroots/wxwindows/wxWindows/src/msw/taskbar.cpp,v
retrieving revision 1.46
diff -u -r1.46 taskbar.cpp
--- src/msw/taskbar.cpp 2005/05/31 09:20:33 1.46
+++ src/msw/taskbar.cpp 2005/08/03 04:56:05
@@ -165,7 +165,6 @@
if ( !tooltip.empty() )
{
notifyData.uFlags |= NIF_TIP;
-// lstrcpyn(notifyData.szTip, tooltip.c_str(), WXSIZEOF(notifyData.szTip));
wxStrncpy(notifyData.szTip, tooltip.c_str(), WXSIZEOF(notifyData.szTip));
}
@@ -315,9 +314,26 @@
case WM_MOUSEMOVE:
eventType = wxEVT_TASKBAR_MOVE;
break;
-
+
+ case NIN_BALLOONSHOW:
+ //NIN_BALLOONSHOW - Sent when the balloon is shown (balloons are queued).
+ eventType = wxEVT_TASKBAR_BALLOON_SHOW;
+ break;
+
+ case NIN_BALLOONHIDE:
+ //NIN_BALLOONHIDE - Sent when the balloon disappears - for example, when the
+ //icon is deleted. This message is not sent if the balloon is dismissed
+ //because of a timeout or a mouse click.
+ eventType = wxEVT_TASKBAR_BALLOON_HIDE;
+ break;
+
+ case NIN_BALLOONUSERCLICK:
+ //NIN_BALLOONUSERCLICK - Sent when the balloon is dismissed because of a mouse click.
+ eventType = wxEVT_TASKBAR_BALLOON_CLICK;
+ break;
+
default:
- break;
+ break;
}
if (eventType)
@@ -328,6 +344,25 @@
}
return 0;
+}
+
+bool wxTaskBarIcon::ShowBalloon(wxString title, wxString message, unsigned int timeout, int icon)
+{
+ if (!IsOk())
+ return false;
+
+ NotifyIconData notifyData((HWND)m_win->GetHWND());
+ notifyData.uFlags = NIF_INFO;
+
+ wxStrncpy(notifyData.szInfo, message.c_str(), WXSIZEOF(notifyData.szInfo));
+ wxStrncpy(notifyData.szInfoTitle, title.c_str(), WXSIZEOF(notifyData.szInfoTitle));
+ notifyData.dwInfoFlags = icon;
+ notifyData.uTimeout = timeout;
+
+ if (m_iconAdded)
+ return Shell_NotifyIcon(NIM_MODIFY, ¬ifyData);
+ else
+ return false;
}
#endif // __WIN95__
EVT_TASKBAR_BALLOON_HIDE will be triggered when the balloon is deleted by the program. It isnt sent when the user dismisses the balloon
EVT_TASKBAR_BALLOON_CLICK will be triggered when the user clicks on the balloon
-
- In need of some credit
- Posts: 7
- Joined: Thu Feb 16, 2006 8:36 pm
- Ryan Norton
- wxWorld Domination!
- Posts: 1319
- Joined: Mon Aug 30, 2004 6:01 pm
Digital Mars compiler has some problem with NOTIFYICONDATA....Ryan Norton wrote:Nice Lowjoel - Kudos!
As for it in a seperate class, well that is a good idea as well...
Code: Select all
notifyData.uFlags |= NIF_INFO;
^
src\taskbarIcon.cpp(23) : Error: undefined identifier 'NIF_INFO'
lstrcpyn(notifyData.szInfo, WXSTRINGCAST message, sizeof(notifyData.szInfo));
^
src\taskbarIcon.cpp(25) : Error: 'szInfo' is not a member of struct '_NOTIFYICONDATAA'
lstrcpyn(notifyData.szInfoTitle, WXSTRINGCAST title, sizeof(notifyData.szInfoTitle));
[...]
steal don't get this
Hello, this is my first message here, I have been using wxWidgets for around 2 months now( I used it before for a while).
Ok, my problem is with this balloon tooltip and the systray. I have tried this code many times but I can't get it to work... I use to work with Linux (crosscompiling with mingw32 for win32) but now I am using a WinXP with devcpp 4.9.9.2 and wxWidgets 2.6.2, and I have the same problem:
As stated by [email protected] upper in this thread, when I do
notifyData.hWnd = (HWND) m_win->GetHWND();
I get this error:
627 C:\install\developer\wx\winsrc\Accounts.cpp invalid use of undefined type `struct wxTaskBarIconWindow'
23 C:\Dev-Cpp\include\wx\msw\taskbar.h forward declaration of `struct wxTaskBarIconWindow'
I don`t know how to fix this...Ok I hope anybody can help me,
Thanks in advance,
Martin
Ok, my problem is with this balloon tooltip and the systray. I have tried this code many times but I can't get it to work... I use to work with Linux (crosscompiling with mingw32 for win32) but now I am using a WinXP with devcpp 4.9.9.2 and wxWidgets 2.6.2, and I have the same problem:
As stated by [email protected] upper in this thread, when I do
notifyData.hWnd = (HWND) m_win->GetHWND();
I get this error:
627 C:\install\developer\wx\winsrc\Accounts.cpp invalid use of undefined type `struct wxTaskBarIconWindow'
23 C:\Dev-Cpp\include\wx\msw\taskbar.h forward declaration of `struct wxTaskBarIconWindow'
I don`t know how to fix this...Ok I hope anybody can help me,
Thanks in advance,
Martin
-
- Part Of The Furniture
- Posts: 1511
- Joined: Sun Jun 19, 2005 11:37 am
- Location: Singapore
- Contact:
Hey guys,
sorry, have been VERY busy lately, and I probably wont be on the forum much anymore
Oldest to newest:
Trikko: define _WIN32_IE > 0x500 (0x600 is best - though 0x500 is the min)
KSmith: I have a working one at the moment, but I'm nt releasing it (yet). See http://joelsplace.sg/documents/files/pu ... -login.png
mromanuk: please provide some code to show me.
Best regards,
Joel
sorry, have been VERY busy lately, and I probably wont be on the forum much anymore
Oldest to newest:
Trikko: define _WIN32_IE > 0x500 (0x600 is best - though 0x500 is the min)
KSmith: I have a working one at the moment, but I'm nt releasing it (yet). See http://joelsplace.sg/documents/files/pu ... -login.png
mromanuk: please provide some code to show me.
Best regards,
Joel
Guys, I've read the posts above and tried to get the ballon tips to work, and I just can't, get things to compile.
I get the following errors:
`sm_taskbarMsg' undeclared (first use this function)
'struct NOTIFYICONDATA' has no member named 'szInfo'
Does, anyone have a working example, I'm using wxDevCpp 6.10
Thanks...
I get the following errors:
`sm_taskbarMsg' undeclared (first use this function)
'struct NOTIFYICONDATA' has no member named 'szInfo'
Does, anyone have a working example, I'm using wxDevCpp 6.10
Thanks...
-
- In need of some credit
- Posts: 9
- Joined: Tue Aug 09, 2005 5:55 pm
- Location: The Netherlands
Any working examples...?
Thanks for the ideas, I've tried both of the above, still no good.
Any change someone could give me a working example, with include statements of the relavent files...?
Thanks in advanced.
Any change someone could give me a working example, with include statements of the relavent files...?
Thanks in advanced.