+// wrapper around Shell_NotifyIcon(): this function is not present in Win95
+// shell32.dll so load it dynamically to allow programs using wxTaskBarIcon to
+// start under this OS
+static BOOL wxShellNotifyIcon(DWORD dwMessage, NOTIFYICONDATA *pData)
+{
+#if wxUSE_DYNLIB_CLASS
+ typedef BOOL (WINAPI *Shell_NotifyIcon_t)(DWORD, NOTIFYICONDATA *);
+
+ static Shell_NotifyIcon_t s_pfnShell_NotifyIcon = NULL;
+ static bool s_initialized = false;
+ if ( !s_initialized )
+ {
+ s_initialized = true;
+
+ wxLogNull noLog;
+ wxDynamicLibrary dllShell("shell32.dll");
+ if ( dllShell.IsLoaded() )
+ {
+ wxDL_INIT_FUNC_AW(s_pfn, Shell_NotifyIcon, dllShell);
+ }
+
+ // NB: it's ok to destroy dllShell here, we link to shell32.dll
+ // implicitly so it won't be unloaded
+ }
+
+ return s_pfnShell_NotifyIcon ? (*s_pfnShell_NotifyIcon)(dwMessage, pData)
+ : FALSE;
+#else // !wxUSE_DYNLIB_CLASS
+ return Shell_NotifyIcon(dwMessage, pData);
+#endif // wxUSE_DYNLIB_CLASS/!wxUSE_DYNLIB_CLASS
+}
+
+// ----------------------------------------------------------------------------
+// wxTaskBarIconWindow: helper window
+// ----------------------------------------------------------------------------
+
+// NB: this class serves two purposes:
+// 1. win32 needs a HWND associated with taskbar icon, this provides it
+// 2. we need wxTopLevelWindow so that the app doesn't exit when
+// last frame is closed but there still is a taskbar icon
+class wxTaskBarIconWindow : public wxFrame
+{
+public:
+ wxTaskBarIconWindow(wxTaskBarIcon *icon)
+ : wxFrame(NULL, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0),
+ m_icon(icon)
+ {
+ }
+
+ WXLRESULT MSWWindowProc(WXUINT msg,
+ WXWPARAM wParam, WXLPARAM lParam)
+ {
+ if (msg == gs_msgRestartTaskbar || msg == gs_msgTaskbar)
+ {
+ return m_icon->WindowProc(msg, wParam, lParam);
+ }
+ else
+ {
+ return wxFrame::MSWWindowProc(msg, wParam, lParam);
+ }
+ }
+
+private:
+ wxTaskBarIcon *m_icon;
+};
+
+