Author: Chaobin Zhang git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@77574 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
97 lines
2.4 KiB
C++
97 lines
2.4 KiB
C++
/////////////////////////////////////////////////////////////////////////////
|
|
// Name: src/msw/taskbarbutton.cpp
|
|
// Purpose: Implements wxTaskBarButtonImpl class for manipulating buttons on
|
|
// the Windows taskbar.
|
|
// Author: Chaobin Zhang <zhchbin@gmail.com>
|
|
// Created: 2014-06-01
|
|
// Copyright: (c) 2014 wxWidgets development team
|
|
// Licence: wxWindows licence
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
#include "wx/wxprec.h"
|
|
|
|
#ifdef __BORLANDC__
|
|
#pragma hdrstop
|
|
#endif
|
|
|
|
#if wxUSE_TASKBARBUTTON
|
|
|
|
#include "wx/msw/wrapshl.h"
|
|
#include "wx/msw/private.h"
|
|
#include "wx/taskbarbutton.h"
|
|
|
|
#include <Shobjidl.h>
|
|
|
|
wxTaskBarButtonImpl::wxTaskBarButtonImpl(WXWidget parent)
|
|
: m_hwnd(parent), m_taskbarList(NULL)
|
|
{
|
|
HRESULT hr = CoCreateInstance
|
|
(
|
|
CLSID_TaskbarList,
|
|
NULL,
|
|
CLSCTX_ALL,
|
|
IID_ITaskbarList3,
|
|
reinterpret_cast<void **>(&m_taskbarList)
|
|
);
|
|
if ( FAILED(hr) )
|
|
{
|
|
wxLogApiError(wxT("CoCreateInstance(CLSID_TaskbarButtonList)"), hr);
|
|
return;
|
|
}
|
|
|
|
hr = m_taskbarList->HrInit();
|
|
if ( FAILED(hr) )
|
|
{
|
|
wxLogApiError(wxT("ITaskbarButtonList3::Init"), hr);
|
|
return;
|
|
}
|
|
}
|
|
|
|
wxTaskBarButtonImpl::~wxTaskBarButtonImpl()
|
|
{
|
|
if ( m_taskbarList )
|
|
m_taskbarList->Release();
|
|
}
|
|
|
|
void wxTaskBarButtonImpl::SetProgressValue(int value)
|
|
{
|
|
wxCHECK_RET( value >= 0 && value <= 100,
|
|
wxT("Invalid value, must be in the range of [0, 100].") );
|
|
|
|
m_taskbarList->SetProgressValue(m_hwnd, value, 100);
|
|
}
|
|
|
|
void wxTaskBarButtonImpl::Show()
|
|
{
|
|
m_taskbarList->AddTab(m_hwnd);
|
|
}
|
|
|
|
void wxTaskBarButtonImpl::Hide()
|
|
{
|
|
m_taskbarList->DeleteTab(m_hwnd);
|
|
}
|
|
|
|
void wxTaskBarButtonImpl::SetThumbnailTooltip(const wxString& tooltip)
|
|
{
|
|
m_taskbarList->SetThumbnailTooltip(m_hwnd, tooltip.wc_str());
|
|
}
|
|
|
|
void wxTaskBarButtonImpl::SetProgressState(wxTaskBarButtonState state)
|
|
{
|
|
m_taskbarList->SetProgressState(m_hwnd, static_cast<TBPFLAG>(state));
|
|
}
|
|
|
|
void wxTaskBarButtonImpl::SetOverlayIcon(const wxIcon& icon)
|
|
{
|
|
m_taskbarList->SetOverlayIcon(m_hwnd, GetHiconOf(icon), NULL);
|
|
}
|
|
|
|
void wxTaskBarButtonImpl::SetThumbnailClip(const wxRect& rect)
|
|
{
|
|
RECT rc;
|
|
wxCopyRectToRECT(rect, rc);
|
|
m_taskbarList->SetThumbnailClip(m_hwnd, rect.IsEmpty() ? NULL : &rc);
|
|
}
|
|
|
|
#endif // wxUSE_TASKBARBUTTON
|