I posted this on wx-dev list,but in case not everyone reads this list.
Well the forum version does actually not work with 2.5.3
No m_hWnd member anymore, but a wxTaskBarIconWindow * m_win,
where wxTaskBarIconWindow is deifined inside taskbar.cpp meaning its not
accessible from a user.
I made a quite hackish workaround and wrote the following code.
Code: Select all
#ifdef wxHAS_TASK_BAR_ICON
#include "wx/taskbar.h"
#ifdef __WXMSW__
#include <ShellAPI.h>
//
// Here i define wxTaskBarIconWindow as it is only define privately in
taskbar,cpp of wxwidgets
// This is a hack, but which choice do i have else?
class wxTaskBarIconWindow : public wxFrame
{
public:
wxTaskBarIconWindow(wxTaskBarIcon *icon)
: wxFrame(NULL, wxID_ANY, wxEmptyString, wxDefaultPosition,
wxDefaultSize, 0),
m_icon(icon)
{
}
private:
wxTaskBarIcon *m_icon;
};
#endif
//quite hackish attempt to be able to compile with release 2.5.2 and cvs
HEAD before 2.5.3 release
#if wxVERSION_NUMBER < 2503
#ifndef wxSUBRELEASE_NUMBER
#define wxTaskBarIconEvent wxEvent
#endif
#endif
class MusikTaskBarIcon: public wxTaskBarIcon
{
public:
MusikTaskBarIcon(wxFrame * frame)
{
#ifdef __WXMSW__
m_dwShellDllVersion = GetDllVersion(wxT("shell32.dll"));
#endif
m_pFrame = frame;
};
virtual bool SetIcon(const wxIcon& icon,
const wxString& tooltip = wxEmptyString)
{
bool bRes = false;
#ifndef __WXMSW__
bRes = wxTaskBarIcon::SetIcon(icon,tooltip);
#else
if(m_dwShellDllVersion < PACKVERSION(5,00))
bRes = wxTaskBarIcon::SetIcon(icon,tooltip);
else
{
// we can use NOTIFYICONDATA V2,where the szTip has 128 chars instead of 64
bRes = wxTaskBarIcon::SetIcon(icon,wxEmptyString); //just set the icon.
if(!tooltip.empty())
{// now set the tooltip text with the help of NOTIFYICONDATA V2 struct.
NOTIFYICONDATA nid;
memset(&nid,0,sizeof(nid));
nid.cbSize = NOTIFYICONDATAW_V2_SIZE;
nid.hWnd = (HWND)m_win->GetHWND();
nid.uID = 99;
nid.uFlags = NIF_TIP;
wxStrncpy(nid.szTip, tooltip.c_str(), WXSIZEOF(nid.szTip));
Shell_NotifyIcon(NIM_MODIFY, &nid);
}
}
#endif
return bRes;
}
#ifdef __WXMSW__
virtual bool ShowBalloonInfo(const wxString &sTitle,const wxString &sText)
{
bool bRes = true;
if(m_dwShellDllVersion >= PACKVERSION(5,00))
{
NOTIFYICONDATA nid;
memset(&nid,0,sizeof(nid));
nid.cbSize = NOTIFYICONDATAW_V2_SIZE;
nid.hWnd = (HWND)m_win->GetHWND();
nid.uID = 99;
nid.uFlags = NIF_INFO;
wxStrncpy(nid.szInfo, sText.c_str(), WXSIZEOF(nid.szInfo));
wxStrncpy(nid.szInfoTitle, sTitle.c_str(), WXSIZEOF(nid.szInfoTitle));
nid.dwInfoFlags = NIIF_NOSOUND|NIIF_INFO;
nid.uTimeout = 5000;
Shell_NotifyIcon(NIM_MODIFY, &nid);
}
else
return false;
return bRes;
}
#endif
void RestoreFrame();
void OnRButtonUp(wxTaskBarIconEvent&);
void OnLButtonDown(wxTaskBarIconEvent&);
void OnMenuRestore(wxCommandEvent&);
void OnMenuHide(wxCommandEvent&);
void OnMenuPlayPause(wxCommandEvent&);
void OnMenuPrev(wxCommandEvent&);
void OnMenuNext(wxCommandEvent&);
void OnMenuStop(wxCommandEvent&);
void OnMenuExit(wxCommandEvent&);
void OnMenuSetNewIcon(wxCommandEvent&);
void OnUpdateUIRateSel ( wxUpdateUIEvent &event);
void OnMenuRateSel( wxCommandEvent& event );
DECLARE_EVENT_TABLE()
private:
wxFrame *m_pFrame;
#ifdef __WXMSW__
DWORD m_dwShellDllVersion;
#endif
};
set _WIN32_IE=0x0600
in your projects preprocessor definitions.
the code of GetDllVersion(LPCTSTR dll)
can be found in the MSDN.
Maybe someone likes to incorporate this code into wxwidgets.
Instead of GetDllVersion(LPCTSTR dll) a more general version of
wxApp:GetComCtlVeersion() could be made.
EDIT: I added syntax highlighting, please use the [ syntax ] tag for code, or at least [ code ]
regards,
gunnar
EDIT: Updated the "tag" again to wxWidgtes syntax highlighting
Greetz,
upCASE