diff --git a/include/wx/msw/taskbarbutton.h b/include/wx/msw/taskbarbutton.h index 0535d74941..4ef0f609a6 100644 --- a/include/wx/msw/taskbarbutton.h +++ b/include/wx/msw/taskbarbutton.h @@ -22,7 +22,6 @@ class WXDLLIMPEXP_FWD_CORE wxITaskbarList3; class WXDLLIMPEXP_CORE wxTaskBarButtonImpl : public wxTaskBarButton { public: - wxTaskBarButtonImpl(wxWindow* parent); virtual ~wxTaskBarButtonImpl(); virtual void SetProgressRange(int range) wxOVERRIDE; @@ -47,6 +46,9 @@ public: bool InitOrUpdateThumbBarButtons(); private: + // This ctor is only used by wxTaskBarButton::New() + wxTaskBarButtonImpl(wxITaskbarList3* taskbarList, wxWindow* parent); + WXHWND m_hwnd; wxITaskbarList3 *m_taskbarList; @@ -56,6 +58,8 @@ private: int m_progressRange; bool m_hasInitThumbnailToolbar; + friend wxTaskBarButton* wxTaskBarButton::New(wxWindow*); + wxDECLARE_NO_COPY_CLASS(wxTaskBarButtonImpl); }; diff --git a/include/wx/taskbarbutton.h b/include/wx/taskbarbutton.h index 6470253356..1652cc560f 100644 --- a/include/wx/taskbarbutton.h +++ b/include/wx/taskbarbutton.h @@ -106,7 +106,10 @@ private: class WXDLLIMPEXP_CORE wxTaskBarButton { public: - wxTaskBarButton() { } + // Factory function, may return NULL if task bar buttons are not supported + // by the current system. + static wxTaskBarButton* New(wxWindow* parent); + virtual ~wxTaskBarButton() { } // Operations: @@ -127,6 +130,9 @@ public: virtual wxThumbBarButton* RemoveThumbBarButton(wxThumbBarButton *button) = 0; virtual wxThumbBarButton* RemoveThumbBarButton(int id) = 0; +protected: + wxTaskBarButton() { } + private: wxDECLARE_NO_COPY_CLASS(wxTaskBarButton); }; diff --git a/src/msw/appprogress.cpp b/src/msw/appprogress.cpp index dd68ec9694..f23836bee1 100644 --- a/src/msw/appprogress.cpp +++ b/src/msw/appprogress.cpp @@ -33,12 +33,16 @@ wxAppProgressIndicator::wxAppProgressIndicator(wxWindow* parent, int maxValue) it != wxTopLevelWindows.end(); ++it ) { - m_taskBarButtons.push_back(new wxTaskBarButtonImpl(*it)); + wxTaskBarButton* const button = wxTaskBarButton::New(*it); + if ( button ) + m_taskBarButtons.push_back(button); } } else { - m_taskBarButtons.push_back(new wxTaskBarButtonImpl(parent)); + wxTaskBarButton* const button = wxTaskBarButton::New(parent); + if ( button ) + m_taskBarButtons.push_back(button); } Reset(); diff --git a/src/msw/frame.cpp b/src/msw/frame.cpp index 7e9273c964..0114feba9f 100644 --- a/src/msw/frame.cpp +++ b/src/msw/frame.cpp @@ -991,7 +991,7 @@ WXLRESULT wxFrame::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lPara #if wxUSE_TASKBARBUTTON if ( message == wxMsgTaskbarButtonCreated ) { - m_taskBarButton = new wxTaskBarButtonImpl(this); + m_taskBarButton = wxTaskBarButton::New(this); processed = true; } #endif