X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/4f167b46b42b81f8f646e594057535f05b05027f..47b4bc17684eecb35429df32c0a9f578ac331310:/src/msw/taskbar.cpp?ds=sidebyside diff --git a/src/msw/taskbar.cpp b/src/msw/taskbar.cpp index 0a6277803f..52e05fee69 100644 --- a/src/msw/taskbar.cpp +++ b/src/msw/taskbar.cpp @@ -26,20 +26,15 @@ #include "wx/menu.h" #endif -#include "wx/msw/private.h" -#include "wx/msw/winundef.h" +#include "wx/msw/wrapshl.h" #include #include "wx/taskbar.h" - -#ifdef __WXWINCE__ - #include - #include -#endif +#include "wx/dynlib.h" // initialized on demand -UINT gs_msgTaskbar = 0; -UINT gs_msgRestartTaskbar = 0; +static UINT gs_msgTaskbar = 0; +static UINT gs_msgRestartTaskbar = 0; IMPLEMENT_DYNAMIC_CLASS(wxTaskBarIcon, wxEvtHandler) @@ -48,6 +43,38 @@ IMPLEMENT_DYNAMIC_CLASS(wxTaskBarIcon, wxEvtHandler) // implementation // ============================================================================ +// 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 // ---------------------------------------------------------------------------- @@ -153,8 +180,8 @@ bool wxTaskBarIcon::SetIcon(const wxIcon& icon, const wxString& tooltip) wxStrncpy(notifyData.szTip, tooltip.c_str(), WXSIZEOF(notifyData.szTip)); } - bool ok = Shell_NotifyIcon(m_iconAdded ? NIM_MODIFY - : NIM_ADD, ¬ifyData) != 0; + bool ok = wxShellNotifyIcon(m_iconAdded ? NIM_MODIFY + : NIM_ADD, ¬ifyData) != 0; if ( !m_iconAdded && ok ) m_iconAdded = true; @@ -171,7 +198,7 @@ bool wxTaskBarIcon::RemoveIcon() NotifyIconData notifyData(GetHwndOf(m_win)); - return Shell_NotifyIcon(NIM_DELETE, ¬ifyData) != 0; + return wxShellNotifyIcon(NIM_DELETE, ¬ifyData) != 0; } #if wxUSE_MENUS