Work around the limitation of windows API when setting thumbnail toolbar buttons.
- New API: InsertThumbBarButton, AppendThumbBarButton, RemoveThumbBarButton. - Though MSDN said that "Buttons cannot be added or deleted later, so this must be the full defined set. Buttons also cannot be reordered.", we can work around it by: when first time adding button, initialize all of the possible seven buttons and hide them, except the button adding. In the next time adding button, just show it, which can make it looks like it is added on the fly. Author: Chaobin Zhang git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@77602 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -32,13 +32,19 @@ public:
|
|||||||
const wxString& description = wxString()) wxOVERRIDE;
|
const wxString& description = wxString()) wxOVERRIDE;
|
||||||
virtual void SetThumbnailClip(const wxRect& rect) wxOVERRIDE;
|
virtual void SetThumbnailClip(const wxRect& rect) wxOVERRIDE;
|
||||||
virtual void SetThumbnailContents(const wxWindow *child) wxOVERRIDE;
|
virtual void SetThumbnailContents(const wxWindow *child) wxOVERRIDE;
|
||||||
virtual bool AddThumbBarButton(wxThumbBarButton *button) wxOVERRIDE;
|
virtual bool InsertThumbBarButton(size_t pos,
|
||||||
virtual void ShowThumbnailToolbar() wxOVERRIDE;
|
wxThumbBarButton *button) wxOVERRIDE;
|
||||||
|
virtual bool AppendThumbBarButton(wxThumbBarButton *button) wxOVERRIDE;
|
||||||
|
virtual bool RemoveThumbBarButton(wxThumbBarButton *button) wxOVERRIDE;
|
||||||
|
virtual bool RemoveThumbBarButton(int id) wxOVERRIDE;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class wxFrame;
|
friend class wxFrame;
|
||||||
wxTaskBarButtonImpl(WXWidget parent);
|
wxTaskBarButtonImpl(WXWidget parent);
|
||||||
|
|
||||||
|
bool InitOrUpdateThumbBarButtons();
|
||||||
|
int GetThumbBarButtonID(size_t index);
|
||||||
|
|
||||||
WXWidget m_hwnd;
|
WXWidget m_hwnd;
|
||||||
ITaskbarList3 *m_taskbarList;
|
ITaskbarList3 *m_taskbarList;
|
||||||
|
|
||||||
@@ -46,8 +52,7 @@ private:
|
|||||||
wxThumbBarButtons m_thumbBarButtons;
|
wxThumbBarButtons m_thumbBarButtons;
|
||||||
|
|
||||||
int m_progressRange;
|
int m_progressRange;
|
||||||
|
bool m_hasInitThumbnailToolbar;
|
||||||
bool m_hasShownThumbnailToolbar;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // wxUSE_TASKBARBUTTON
|
#endif // wxUSE_TASKBARBUTTON
|
||||||
|
@@ -13,6 +13,8 @@
|
|||||||
|
|
||||||
#if wxUSE_TASKBARBUTTON
|
#if wxUSE_TASKBARBUTTON
|
||||||
|
|
||||||
|
#include "wx/defs.h"
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxTaskBarButton: define wxTaskBarButton interface.
|
// wxTaskBarButton: define wxTaskBarButton interface.
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -33,18 +35,33 @@ class WXDLLIMPEXP_ADV wxThumbBarButton {
|
|||||||
public:
|
public:
|
||||||
wxThumbBarButton(int id,
|
wxThumbBarButton(int id,
|
||||||
const wxIcon& icon,
|
const wxIcon& icon,
|
||||||
const wxString& tooltip = wxString());
|
const wxString& tooltip = wxString(),
|
||||||
|
bool enable = true,
|
||||||
|
bool dismissOnClick = false,
|
||||||
|
bool hasBackground = true,
|
||||||
|
bool shown = true,
|
||||||
|
bool interactive = true);
|
||||||
|
|
||||||
virtual ~wxThumbBarButton() {}
|
virtual ~wxThumbBarButton() {}
|
||||||
|
|
||||||
int GetID() const { return m_id; }
|
int GetID() const { return m_id; }
|
||||||
const wxIcon& GetIcon() const { return m_icon; }
|
const wxIcon& GetIcon() const { return m_icon; }
|
||||||
const wxString& GetTooltip() const { return m_tooltip; }
|
const wxString& GetTooltip() const { return m_tooltip; }
|
||||||
|
bool IsEnable() const { return m_enable; }
|
||||||
|
bool IsDismissOnClick() const { return m_dismissOnClick; }
|
||||||
|
bool HasBackground() const { return m_hasBackground; }
|
||||||
|
bool IsShown() const { return m_shown; }
|
||||||
|
bool IsInteractive() const { return m_interactive; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int m_id;
|
int m_id;
|
||||||
wxIcon m_icon;
|
wxIcon m_icon;
|
||||||
wxString m_tooltip;
|
wxString m_tooltip;
|
||||||
|
bool m_enable;
|
||||||
|
bool m_dismissOnClick;
|
||||||
|
bool m_hasBackground;
|
||||||
|
bool m_shown;
|
||||||
|
bool m_interactive;
|
||||||
};
|
};
|
||||||
|
|
||||||
class WXDLLIMPEXP_ADV wxTaskBarButton
|
class WXDLLIMPEXP_ADV wxTaskBarButton
|
||||||
@@ -65,16 +82,10 @@ public:
|
|||||||
const wxString& description = wxString()) = 0;
|
const wxString& description = wxString()) = 0;
|
||||||
virtual void SetThumbnailClip(const wxRect& rect) = 0;
|
virtual void SetThumbnailClip(const wxRect& rect) = 0;
|
||||||
virtual void SetThumbnailContents(const wxWindow *child) = 0;
|
virtual void SetThumbnailContents(const wxWindow *child) = 0;
|
||||||
|
virtual bool InsertThumbBarButton(size_t pos, wxThumbBarButton *button) = 0;
|
||||||
/**
|
virtual bool AppendThumbBarButton(wxThumbBarButton *button) = 0;
|
||||||
Adds a thumbnail toolbar button to the thumbnail image of a window in
|
virtual bool RemoveThumbBarButton(wxThumbBarButton *button) = 0;
|
||||||
the taskbar button flyout. Note that a wxTaskbarButton can only have no
|
virtual bool RemoveThumbBarButton(int id) = 0;
|
||||||
more than seven wxThumbBarButtons, and ShowThumbnailToolbar should be
|
|
||||||
called to show them, then these buttons cannot be added or removed until
|
|
||||||
the window is re-created.
|
|
||||||
*/
|
|
||||||
virtual bool AddThumbBarButton(wxThumbBarButton *button) = 0;
|
|
||||||
virtual void ShowThumbnailToolbar() = 0;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
wxDECLARE_NO_COPY_CLASS(wxTaskBarButton);
|
wxDECLARE_NO_COPY_CLASS(wxTaskBarButton);
|
||||||
|
@@ -30,7 +30,7 @@ enum
|
|||||||
SetThumbnailClipBtn,
|
SetThumbnailClipBtn,
|
||||||
RestoreThumbnailClipBtn,
|
RestoreThumbnailClipBtn,
|
||||||
AddThumbBarButtonBtn,
|
AddThumbBarButtonBtn,
|
||||||
ShowThumbnailToolbarBtn,
|
RemoveThumbBarButtonBtn,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum
|
enum
|
||||||
@@ -114,13 +114,16 @@ private:
|
|||||||
void OnClearOverlayIcon(wxCommandEvent& WXUNUSED(event));
|
void OnClearOverlayIcon(wxCommandEvent& WXUNUSED(event));
|
||||||
void OnSetOrRestoreThumbnailClip(wxCommandEvent& event);
|
void OnSetOrRestoreThumbnailClip(wxCommandEvent& event);
|
||||||
void OnAddThubmBarButton(wxCommandEvent& WXUNUSED(event));
|
void OnAddThubmBarButton(wxCommandEvent& WXUNUSED(event));
|
||||||
void OnShowThumbnailToolbar(wxCommandEvent& WXUNUSED(event));
|
void OnRemoveThubmBarButton(wxCommandEvent& WXUNUSED(event));
|
||||||
void OnThumbnailToolbarBtnClicked(wxCommandEvent& event);
|
void OnThumbnailToolbarBtnClicked(wxCommandEvent& event);
|
||||||
|
|
||||||
wxSlider *m_slider;
|
wxSlider *m_slider;
|
||||||
wxRadioBox *m_visibilityRadioBox;
|
wxRadioBox *m_visibilityRadioBox;
|
||||||
wxTextCtrl *m_textCtrl;
|
wxTextCtrl *m_textCtrl;
|
||||||
wxChoice *m_stateChoice;
|
wxChoice *m_stateChoice;
|
||||||
|
|
||||||
|
typedef wxVector<wxThumbBarButton*> wxThumbBarButtons;
|
||||||
|
wxThumbBarButtons m_thumbBarButtons;
|
||||||
};
|
};
|
||||||
|
|
||||||
IMPLEMENT_APP(MyApp)
|
IMPLEMENT_APP(MyApp)
|
||||||
@@ -215,8 +218,8 @@ MyFrame::MyFrame(const wxString& title)
|
|||||||
wxButton *addThumbBarButtonBtn =
|
wxButton *addThumbBarButtonBtn =
|
||||||
new wxButton(panel, AddThumbBarButtonBtn, wxT("Add ThumbBar Button"));
|
new wxButton(panel, AddThumbBarButtonBtn, wxT("Add ThumbBar Button"));
|
||||||
wxButton *showThumbnailToolbarBtn =
|
wxButton *showThumbnailToolbarBtn =
|
||||||
new wxButton(panel, ShowThumbnailToolbarBtn,
|
new wxButton(panel, RemoveThumbBarButtonBtn,
|
||||||
wxT("Show Thumbnail Toolbar"));
|
wxT("Remove Last ThumbBar Button"));
|
||||||
ttbSizer->Add(addThumbBarButtonBtn, 1, wxEXPAND | wxALL, 2);
|
ttbSizer->Add(addThumbBarButtonBtn, 1, wxEXPAND | wxALL, 2);
|
||||||
ttbSizer->Add(showThumbnailToolbarBtn, 1, wxEXPAND | wxALL, 2);
|
ttbSizer->Add(showThumbnailToolbarBtn, 1, wxEXPAND | wxALL, 2);
|
||||||
|
|
||||||
@@ -250,7 +253,7 @@ wxBEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
|||||||
EVT_BUTTON(SetThumbnailClipBtn, MyFrame::OnSetOrRestoreThumbnailClip)
|
EVT_BUTTON(SetThumbnailClipBtn, MyFrame::OnSetOrRestoreThumbnailClip)
|
||||||
EVT_BUTTON(RestoreThumbnailClipBtn, MyFrame::OnSetOrRestoreThumbnailClip)
|
EVT_BUTTON(RestoreThumbnailClipBtn, MyFrame::OnSetOrRestoreThumbnailClip)
|
||||||
EVT_BUTTON(AddThumbBarButtonBtn, MyFrame::OnAddThubmBarButton)
|
EVT_BUTTON(AddThumbBarButtonBtn, MyFrame::OnAddThubmBarButton)
|
||||||
EVT_BUTTON(ShowThumbnailToolbarBtn, MyFrame::OnShowThumbnailToolbar)
|
EVT_BUTTON(RemoveThumbBarButtonBtn, MyFrame::OnRemoveThubmBarButton)
|
||||||
EVT_BUTTON(ThumbnailToolbarBtn_0, MyFrame::OnThumbnailToolbarBtnClicked)
|
EVT_BUTTON(ThumbnailToolbarBtn_0, MyFrame::OnThumbnailToolbarBtnClicked)
|
||||||
EVT_BUTTON(ThumbnailToolbarBtn_1, MyFrame::OnThumbnailToolbarBtnClicked)
|
EVT_BUTTON(ThumbnailToolbarBtn_1, MyFrame::OnThumbnailToolbarBtnClicked)
|
||||||
EVT_BUTTON(ThumbnailToolbarBtn_2, MyFrame::OnThumbnailToolbarBtnClicked)
|
EVT_BUTTON(ThumbnailToolbarBtn_2, MyFrame::OnThumbnailToolbarBtnClicked)
|
||||||
@@ -311,6 +314,7 @@ void MyFrame::OnChoice(wxCommandEvent& event)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MSWGetTaskBarButton()->SetProgressValue(m_slider->GetValue());
|
||||||
MSWGetTaskBarButton()->SetProgressState(state);
|
MSWGetTaskBarButton()->SetProgressState(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -341,21 +345,27 @@ void MyFrame::OnSetOrRestoreThumbnailClip(wxCommandEvent& event)
|
|||||||
MSWGetTaskBarButton()->SetThumbnailClip(rect);
|
MSWGetTaskBarButton()->SetThumbnailClip(rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MyFrame::OnAddThubmBarButton(wxCommandEvent& WXUNUSED(event))
|
void MyFrame::OnAddThubmBarButton(wxCommandEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
static int thumbBarButtonCounter = 0;
|
if ( m_thumbBarButtons.size() >= 7 )
|
||||||
if ( thumbBarButtonCounter >= 7 )
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
wxThumbBarButton *btn = new wxThumbBarButton(
|
wxThumbBarButton* button =
|
||||||
thumbBarButtonCounter + ThumbnailToolbarBtn_0 , CreateRandomIcon());
|
new wxThumbBarButton(m_thumbBarButtons.size() + ThumbnailToolbarBtn_0 ,
|
||||||
MSWGetTaskBarButton()->AddThumbBarButton(btn);
|
CreateRandomIcon());
|
||||||
++thumbBarButtonCounter;
|
MSWGetTaskBarButton()->AppendThumbBarButton(button);
|
||||||
|
m_thumbBarButtons.push_back(button);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyFrame::OnShowThumbnailToolbar(wxCommandEvent& WXUNUSED(event))
|
void MyFrame::OnRemoveThubmBarButton(wxCommandEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
MSWGetTaskBarButton()->ShowThumbnailToolbar();
|
if ( m_thumbBarButtons.empty() )
|
||||||
|
return;
|
||||||
|
|
||||||
|
wxThumbBarButton* button = m_thumbBarButtons.back();
|
||||||
|
m_thumbBarButtons.pop_back();
|
||||||
|
MSWGetTaskBarButton()->RemoveThumbBarButton(button);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyFrame::OnThumbnailToolbarBtnClicked(wxCommandEvent& event)
|
void MyFrame::OnThumbnailToolbarBtnClicked(wxCommandEvent& event)
|
||||||
|
@@ -905,7 +905,9 @@ bool wxFrame::HandleCommand(WXWORD id, WXWORD cmd, WXHWND control)
|
|||||||
#if wxUSE_TASKBARBUTTON
|
#if wxUSE_TASKBARBUTTON
|
||||||
if ( cmd == wxTHBN_CLICKED && m_taskBarButton )
|
if ( cmd == wxTHBN_CLICKED && m_taskBarButton )
|
||||||
{
|
{
|
||||||
wxCommandEvent event(wxEVT_BUTTON, id);
|
wxTaskBarButtonImpl * const
|
||||||
|
tbButton = reinterpret_cast<wxTaskBarButtonImpl*>(m_taskBarButton);
|
||||||
|
wxCommandEvent event(wxEVT_BUTTON, tbButton->GetThumbBarButtonID(id));
|
||||||
event.SetEventObject(this);
|
event.SetEventObject(this);
|
||||||
return ProcessEvent(event);
|
return ProcessEvent(event);
|
||||||
}
|
}
|
||||||
|
@@ -14,6 +14,10 @@
|
|||||||
#pragma hdrstop
|
#pragma hdrstop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef WX_PRECOMP
|
||||||
|
#include "wx/icon.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#if wxUSE_TASKBARBUTTON
|
#if wxUSE_TASKBARBUTTON
|
||||||
|
|
||||||
#include "wx/msw/wrapshl.h"
|
#include "wx/msw/wrapshl.h"
|
||||||
@@ -22,10 +26,44 @@
|
|||||||
|
|
||||||
#include <Shobjidl.h>
|
#include <Shobjidl.h>
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
// The maximum number of thumbnail toolbar buttons allowed on windows is 7.
|
||||||
|
static const int LIMITED_BUTTON_SIZE = 7;
|
||||||
|
|
||||||
|
THUMBBUTTONFLAGS GetNativeThumbButtonFlags(const wxThumbBarButton& button)
|
||||||
|
{
|
||||||
|
WXUINT flags = 0;
|
||||||
|
flags |= (button.IsEnable() ? THBF_ENABLED : THBF_DISABLED);
|
||||||
|
if ( button.IsDismissOnClick() )
|
||||||
|
flags |= THBF_DISMISSONCLICK;
|
||||||
|
if ( !button.HasBackground() )
|
||||||
|
flags |= THBF_NOBACKGROUND;
|
||||||
|
if ( !button.IsShown() )
|
||||||
|
flags |= THBF_HIDDEN;
|
||||||
|
if ( !button.IsInteractive() )
|
||||||
|
flags |= THBF_NONINTERACTIVE;
|
||||||
|
return static_cast<THUMBBUTTONFLAGS>(flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
wxThumbBarButton::wxThumbBarButton(int id,
|
wxThumbBarButton::wxThumbBarButton(int id,
|
||||||
const wxIcon& icon,
|
const wxIcon& icon,
|
||||||
const wxString& tooltip)
|
const wxString& tooltip,
|
||||||
: m_id(id), m_icon(icon), m_tooltip(tooltip)
|
bool enable,
|
||||||
|
bool dismissOnClick,
|
||||||
|
bool hasBackground,
|
||||||
|
bool shown,
|
||||||
|
bool interactive)
|
||||||
|
: m_id(id),
|
||||||
|
m_icon(icon),
|
||||||
|
m_tooltip(tooltip),
|
||||||
|
m_enable(enable),
|
||||||
|
m_dismissOnClick(dismissOnClick),
|
||||||
|
m_hasBackground(hasBackground),
|
||||||
|
m_shown(shown),
|
||||||
|
m_interactive(interactive)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,7 +71,7 @@ wxTaskBarButtonImpl::wxTaskBarButtonImpl(WXWidget parent)
|
|||||||
: m_hwnd(parent),
|
: m_hwnd(parent),
|
||||||
m_taskbarList(NULL),
|
m_taskbarList(NULL),
|
||||||
m_progressRange(0),
|
m_progressRange(0),
|
||||||
m_hasShownThumbnailToolbar(false)
|
m_hasInitThumbnailToolbar(false)
|
||||||
{
|
{
|
||||||
HRESULT hr = CoCreateInstance
|
HRESULT hr = CoCreateInstance
|
||||||
(
|
(
|
||||||
@@ -52,7 +90,7 @@ wxTaskBarButtonImpl::wxTaskBarButtonImpl(WXWidget parent)
|
|||||||
hr = m_taskbarList->HrInit();
|
hr = m_taskbarList->HrInit();
|
||||||
if ( FAILED(hr) )
|
if ( FAILED(hr) )
|
||||||
{
|
{
|
||||||
wxLogApiError(wxT("ITaskbarButtonList3::Init"), hr);
|
wxLogApiError(wxT("ITaskbarList3::Init"), hr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -131,28 +169,74 @@ void wxTaskBarButtonImpl::SetThumbnailContents(const wxWindow *child)
|
|||||||
SetThumbnailClip(child->GetRect());
|
SetThumbnailClip(child->GetRect());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxTaskBarButtonImpl::AddThumbBarButton(wxThumbBarButton *button)
|
bool wxTaskBarButtonImpl::AppendThumbBarButton(wxThumbBarButton *button)
|
||||||
{
|
{
|
||||||
wxCHECK( button != NULL, wxT("Can't add invalid wxThumbBarButton.") );
|
if ( m_thumbBarButtons.size() >= LIMITED_BUTTON_SIZE )
|
||||||
if (m_thumbBarButtons.size() >= 7)
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_thumbBarButtons.push_back(button);
|
m_thumbBarButtons.push_back(button);
|
||||||
return true;
|
return InitOrUpdateThumbBarButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxTaskBarButtonImpl::ShowThumbnailToolbar()
|
bool wxTaskBarButtonImpl::InsertThumbBarButton(size_t pos,
|
||||||
|
wxThumbBarButton *button)
|
||||||
{
|
{
|
||||||
if ( m_hasShownThumbnailToolbar || m_thumbBarButtons.empty() )
|
if ( m_thumbBarButtons.size() >= LIMITED_BUTTON_SIZE ||
|
||||||
return;
|
m_thumbBarButtons.size() < pos )
|
||||||
|
return false;
|
||||||
|
|
||||||
THUMBBUTTON buttons[7];
|
m_thumbBarButtons.insert(m_thumbBarButtons.begin() + pos, button);
|
||||||
|
return InitOrUpdateThumbBarButtons();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxTaskBarButtonImpl::RemoveThumbBarButton(wxThumbBarButton *button)
|
||||||
|
{
|
||||||
|
wxThumbBarButtons::iterator it;
|
||||||
|
for ( it = m_thumbBarButtons.begin(); it != m_thumbBarButtons.end(); ++it )
|
||||||
|
{
|
||||||
|
if ( button == *it )
|
||||||
|
{
|
||||||
|
m_thumbBarButtons.erase(it);
|
||||||
|
return InitOrUpdateThumbBarButtons();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxTaskBarButtonImpl::RemoveThumbBarButton(int id)
|
||||||
|
{
|
||||||
|
wxThumbBarButtons::iterator it;
|
||||||
|
for ( it = m_thumbBarButtons.begin(); it != m_thumbBarButtons.end(); ++it )
|
||||||
|
{
|
||||||
|
if ( id == (*it)->GetID() )
|
||||||
|
{
|
||||||
|
m_thumbBarButtons.erase(it);
|
||||||
|
return InitOrUpdateThumbBarButtons();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxTaskBarButtonImpl::InitOrUpdateThumbBarButtons()
|
||||||
|
{
|
||||||
|
THUMBBUTTON buttons[LIMITED_BUTTON_SIZE];
|
||||||
size_t i;
|
size_t i;
|
||||||
|
HRESULT hr;
|
||||||
|
|
||||||
|
for ( i = 0; i < LIMITED_BUTTON_SIZE; ++i )
|
||||||
|
{
|
||||||
|
memset(&buttons[i], 0, sizeof buttons[i]);
|
||||||
|
buttons[i].iId = i;
|
||||||
|
buttons[i].dwFlags = THBF_HIDDEN;
|
||||||
|
buttons[i].dwMask = THB_FLAGS;
|
||||||
|
}
|
||||||
|
|
||||||
for ( i = 0; i < m_thumbBarButtons.size(); ++i )
|
for ( i = 0; i < m_thumbBarButtons.size(); ++i )
|
||||||
{
|
{
|
||||||
buttons[i].iId = m_thumbBarButtons[i]->GetID();
|
|
||||||
buttons[i].hIcon = GetHiconOf(m_thumbBarButtons[i]->GetIcon());
|
buttons[i].hIcon = GetHiconOf(m_thumbBarButtons[i]->GetIcon());
|
||||||
buttons[i].dwFlags = THBF_ENABLED;
|
buttons[i].dwFlags = GetNativeThumbButtonFlags(*m_thumbBarButtons[i]);
|
||||||
buttons[i].dwMask = THB_ICON | THB_FLAGS;
|
buttons[i].dwMask = THB_ICON | THB_FLAGS;
|
||||||
wxString tooltip = m_thumbBarButtons[i]->GetTooltip();
|
wxString tooltip = m_thumbBarButtons[i]->GetTooltip();
|
||||||
if ( tooltip.empty() )
|
if ( tooltip.empty() )
|
||||||
@@ -166,10 +250,37 @@ void wxTaskBarButtonImpl::ShowThumbnailToolbar()
|
|||||||
buttons[i].dwMask |= THB_TOOLTIP;
|
buttons[i].dwMask |= THB_TOOLTIP;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_taskbarList->ThumbBarAddButtons(m_hwnd,
|
if ( !m_hasInitThumbnailToolbar )
|
||||||
m_thumbBarButtons.size(),
|
{
|
||||||
buttons);
|
hr = m_taskbarList->ThumbBarAddButtons(m_hwnd,
|
||||||
m_hasShownThumbnailToolbar = true;
|
LIMITED_BUTTON_SIZE,
|
||||||
|
buttons);
|
||||||
|
if ( FAILED(hr) )
|
||||||
|
{
|
||||||
|
wxLogApiError(wxT("ITaskbarList3::ThumbBarAddButtons"), hr);
|
||||||
|
}
|
||||||
|
m_hasInitThumbnailToolbar = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hr = m_taskbarList->ThumbBarUpdateButtons(m_hwnd,
|
||||||
|
LIMITED_BUTTON_SIZE,
|
||||||
|
buttons);
|
||||||
|
if ( FAILED(hr) )
|
||||||
|
{
|
||||||
|
wxLogApiError(wxT("ITaskbarList3::ThumbBarUpdateButtons"), hr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return SUCCEEDED(hr);
|
||||||
|
}
|
||||||
|
|
||||||
|
int wxTaskBarButtonImpl::GetThumbBarButtonID(size_t index)
|
||||||
|
{
|
||||||
|
if ( index >= m_thumbBarButtons.size() )
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return m_thumbBarButtons[index]->GetID();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // wxUSE_TASKBARBUTTON
|
#endif // wxUSE_TASKBARBUTTON
|
||||||
|
Reference in New Issue
Block a user