diff --git a/include/wx/msw/taskbarbutton.h b/include/wx/msw/taskbarbutton.h index 8637076711..bb910bdde5 100644 --- a/include/wx/msw/taskbarbutton.h +++ b/include/wx/msw/taskbarbutton.h @@ -21,6 +21,8 @@ public: virtual ~wxTaskBarButtonImpl(); virtual void SetProgressValue(int value) wxOVERRIDE; + virtual void ShowInTaskbar() wxOVERRIDE; + virtual void HideInTaskbar() wxOVERRIDE; private: friend class wxTopLevelWindowMSW; diff --git a/include/wx/taskbarbutton.h b/include/wx/taskbarbutton.h index 6b93be69be..9e70dc854d 100644 --- a/include/wx/taskbarbutton.h +++ b/include/wx/taskbarbutton.h @@ -25,6 +25,8 @@ public: // Operations: virtual void SetProgressValue(int value) = 0; + virtual void ShowInTaskbar() = 0; + virtual void HideInTaskbar() = 0; private: wxDECLARE_NO_COPY_CLASS(wxTaskBarButton); diff --git a/samples/taskbarbutton/taskbarbutton.cpp b/samples/taskbarbutton/taskbarbutton.cpp index d4da7a9ab9..80d90ab425 100644 --- a/samples/taskbarbutton/taskbarbutton.cpp +++ b/samples/taskbarbutton/taskbarbutton.cpp @@ -22,6 +22,7 @@ enum { ProgressValueSlider = wxID_HIGHEST, + VisibilityRadio, }; class MyApp : public wxApp @@ -39,8 +40,10 @@ private: wxDECLARE_EVENT_TABLE(); void OnSetProgressValue(wxScrollEvent& WXUNUSED(event)); + void OnVisibilityChange(wxCommandEvent& WXUNUSED(event)); wxSlider *m_slider; + wxRadioBox *m_visibilityRadioBox; }; IMPLEMENT_APP(MyApp) @@ -74,7 +77,19 @@ MyFrame::MyFrame(const wxString& title) m_slider->SetTickFreq(10); spvSizer->Add(m_slider); + // Show/Hide in Taskbar section. + const wxString labels[] = + { + "&Show in Taskbar", + "&Hide in Taskbar" + }; + m_visibilityRadioBox = new wxRadioBox(panel, VisibilityRadio, "Visibility:", + wxDefaultPosition, wxDefaultSize, + WXSIZEOF(labels), labels, + 1, wxRA_SPECIFY_ROWS); + gs->Add(spvSizer, 0, wxEXPAND); + gs->Add(m_visibilityRadioBox, 0, wxEXPAND); wxStaticText *text = new wxStaticText( panel, wxID_ANY, wxT("Welcome to wxTaskbarButton sample")); @@ -90,9 +105,18 @@ MyFrame::MyFrame(const wxString& title) wxBEGIN_EVENT_TABLE(MyFrame, wxFrame) EVT_COMMAND_SCROLL_CHANGED(ProgressValueSlider, MyFrame::OnSetProgressValue) + EVT_RADIOBOX(VisibilityRadio, MyFrame::OnVisibilityChange) wxEND_EVENT_TABLE() void MyFrame::OnSetProgressValue(wxScrollEvent& WXUNUSED(event)) { MSWGetTaskBarButton()->SetProgressValue(m_slider->GetValue()); } + +void MyFrame::OnVisibilityChange(wxCommandEvent& WXUNUSED(event)) +{ + if ( m_visibilityRadioBox->GetSelection() == 0 ) + MSWGetTaskBarButton()->ShowInTaskbar(); + else + MSWGetTaskBarButton()->HideInTaskbar(); +} diff --git a/src/msw/taskbarbutton.cpp b/src/msw/taskbarbutton.cpp index 96f3142a65..fdfe6a61f9 100644 --- a/src/msw/taskbarbutton.cpp +++ b/src/msw/taskbarbutton.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // Name: src/msw/taskbarbutton.cpp -// Purpose: Implements wxTaskbarButtonImpl class for manipulating buttons on +// Purpose: Implements wxTaskBarButtonImpl class for manipulating buttons on // the Windows taskbar. // Author: Chaobin Zhang // Created: 2014-06-01 @@ -22,7 +22,8 @@ #include -wxTaskBarButtonImpl::wxTaskBarButtonImpl(WXWidget parent) : m_hwnd(parent) +wxTaskBarButtonImpl::wxTaskBarButtonImpl(WXWidget parent) + : m_hwnd(parent), m_taskbarList(NULL) { HRESULT hr = CoCreateInstance ( @@ -60,4 +61,14 @@ void wxTaskBarButtonImpl::SetProgressValue(int value) m_taskbarList->SetProgressValue(m_hwnd, value, 100); } +void wxTaskBarButtonImpl::ShowInTaskbar() +{ + m_taskbarList->AddTab(m_hwnd); +} + +void wxTaskBarButtonImpl::HideInTaskbar() +{ + m_taskbarList->DeleteTab(m_hwnd); +} + #endif // wxUSE_TASKBARBUTTON