API for change the visibility of button in the taskbar.
- ShowInTaskbar and HideInTaskbar - Sample of usage. Author: Chaobin Zhang git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@77573 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -21,6 +21,8 @@ public:
|
|||||||
virtual ~wxTaskBarButtonImpl();
|
virtual ~wxTaskBarButtonImpl();
|
||||||
|
|
||||||
virtual void SetProgressValue(int value) wxOVERRIDE;
|
virtual void SetProgressValue(int value) wxOVERRIDE;
|
||||||
|
virtual void ShowInTaskbar() wxOVERRIDE;
|
||||||
|
virtual void HideInTaskbar() wxOVERRIDE;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class wxTopLevelWindowMSW;
|
friend class wxTopLevelWindowMSW;
|
||||||
|
@@ -25,6 +25,8 @@ public:
|
|||||||
|
|
||||||
// Operations:
|
// Operations:
|
||||||
virtual void SetProgressValue(int value) = 0;
|
virtual void SetProgressValue(int value) = 0;
|
||||||
|
virtual void ShowInTaskbar() = 0;
|
||||||
|
virtual void HideInTaskbar() = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
wxDECLARE_NO_COPY_CLASS(wxTaskBarButton);
|
wxDECLARE_NO_COPY_CLASS(wxTaskBarButton);
|
||||||
|
@@ -22,6 +22,7 @@
|
|||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
ProgressValueSlider = wxID_HIGHEST,
|
ProgressValueSlider = wxID_HIGHEST,
|
||||||
|
VisibilityRadio,
|
||||||
};
|
};
|
||||||
|
|
||||||
class MyApp : public wxApp
|
class MyApp : public wxApp
|
||||||
@@ -39,8 +40,10 @@ private:
|
|||||||
wxDECLARE_EVENT_TABLE();
|
wxDECLARE_EVENT_TABLE();
|
||||||
|
|
||||||
void OnSetProgressValue(wxScrollEvent& WXUNUSED(event));
|
void OnSetProgressValue(wxScrollEvent& WXUNUSED(event));
|
||||||
|
void OnVisibilityChange(wxCommandEvent& WXUNUSED(event));
|
||||||
|
|
||||||
wxSlider *m_slider;
|
wxSlider *m_slider;
|
||||||
|
wxRadioBox *m_visibilityRadioBox;
|
||||||
};
|
};
|
||||||
|
|
||||||
IMPLEMENT_APP(MyApp)
|
IMPLEMENT_APP(MyApp)
|
||||||
@@ -74,7 +77,19 @@ MyFrame::MyFrame(const wxString& title)
|
|||||||
m_slider->SetTickFreq(10);
|
m_slider->SetTickFreq(10);
|
||||||
spvSizer->Add(m_slider);
|
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(spvSizer, 0, wxEXPAND);
|
||||||
|
gs->Add(m_visibilityRadioBox, 0, wxEXPAND);
|
||||||
|
|
||||||
wxStaticText *text = new wxStaticText(
|
wxStaticText *text = new wxStaticText(
|
||||||
panel, wxID_ANY, wxT("Welcome to wxTaskbarButton sample"));
|
panel, wxID_ANY, wxT("Welcome to wxTaskbarButton sample"));
|
||||||
@@ -90,9 +105,18 @@ MyFrame::MyFrame(const wxString& title)
|
|||||||
|
|
||||||
wxBEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
wxBEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
||||||
EVT_COMMAND_SCROLL_CHANGED(ProgressValueSlider, MyFrame::OnSetProgressValue)
|
EVT_COMMAND_SCROLL_CHANGED(ProgressValueSlider, MyFrame::OnSetProgressValue)
|
||||||
|
EVT_RADIOBOX(VisibilityRadio, MyFrame::OnVisibilityChange)
|
||||||
wxEND_EVENT_TABLE()
|
wxEND_EVENT_TABLE()
|
||||||
|
|
||||||
void MyFrame::OnSetProgressValue(wxScrollEvent& WXUNUSED(event))
|
void MyFrame::OnSetProgressValue(wxScrollEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
MSWGetTaskBarButton()->SetProgressValue(m_slider->GetValue());
|
MSWGetTaskBarButton()->SetProgressValue(m_slider->GetValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MyFrame::OnVisibilityChange(wxCommandEvent& WXUNUSED(event))
|
||||||
|
{
|
||||||
|
if ( m_visibilityRadioBox->GetSelection() == 0 )
|
||||||
|
MSWGetTaskBarButton()->ShowInTaskbar();
|
||||||
|
else
|
||||||
|
MSWGetTaskBarButton()->HideInTaskbar();
|
||||||
|
}
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// Name: src/msw/taskbarbutton.cpp
|
// Name: src/msw/taskbarbutton.cpp
|
||||||
// Purpose: Implements wxTaskbarButtonImpl class for manipulating buttons on
|
// Purpose: Implements wxTaskBarButtonImpl class for manipulating buttons on
|
||||||
// the Windows taskbar.
|
// the Windows taskbar.
|
||||||
// Author: Chaobin Zhang <zhchbin@gmail.com>
|
// Author: Chaobin Zhang <zhchbin@gmail.com>
|
||||||
// Created: 2014-06-01
|
// Created: 2014-06-01
|
||||||
@@ -22,7 +22,8 @@
|
|||||||
|
|
||||||
#include <Shobjidl.h>
|
#include <Shobjidl.h>
|
||||||
|
|
||||||
wxTaskBarButtonImpl::wxTaskBarButtonImpl(WXWidget parent) : m_hwnd(parent)
|
wxTaskBarButtonImpl::wxTaskBarButtonImpl(WXWidget parent)
|
||||||
|
: m_hwnd(parent), m_taskbarList(NULL)
|
||||||
{
|
{
|
||||||
HRESULT hr = CoCreateInstance
|
HRESULT hr = CoCreateInstance
|
||||||
(
|
(
|
||||||
@@ -60,4 +61,14 @@ void wxTaskBarButtonImpl::SetProgressValue(int value)
|
|||||||
m_taskbarList->SetProgressValue(m_hwnd, value, 100);
|
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
|
#endif // wxUSE_TASKBARBUTTON
|
||||||
|
Reference in New Issue
Block a user