Make wxAppProgressIndicator actually usable.

First of all, do define it under non-MSW platforms.

Second, don't crash in it when running under XP where wxTaskBarButton is not
available.

Also add IsAvailable() method to check for its availability explicitly and add
a demonstration of this class to the dialogs sample.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@77706 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2014-09-14 23:58:26 +00:00
parent 03e245091f
commit 28516f5643
7 changed files with 92 additions and 10 deletions

View File

@@ -696,32 +696,46 @@ bool wxThumbBarButton::UpdateParentTaskBarButton()
// ----------------------------------------------------------------------------
// wxTaskBarButtonImpl Implementation.
// ----------------------------------------------------------------------------
wxTaskBarButtonImpl::wxTaskBarButtonImpl(wxWindow* parent)
: m_hwnd(parent->GetHandle()),
m_taskbarList(NULL),
m_progressRange(0),
m_hasInitThumbnailToolbar(false)
/* static */
wxTaskBarButton* wxTaskBarButton::New(wxWindow* parent)
{
wxITaskbarList3* taskbarList = NULL;
HRESULT hr = CoCreateInstance
(
wxCLSID_TaskbarList,
NULL,
CLSCTX_INPROC_SERVER,
wxIID_ITaskbarList3,
reinterpret_cast<void **>(&m_taskbarList)
reinterpret_cast<void **>(&taskbarList)
);
if ( FAILED(hr) )
{
wxLogApiError(wxT("CoCreateInstance(wxCLSID_TaskbarList)"), hr);
return;
// Don't log this error, it may be normal when running under XP.
return NULL;
}
hr = m_taskbarList->HrInit();
hr = taskbarList->HrInit();
if ( FAILED(hr) )
{
// This is however unexpected.
wxLogApiError(wxT("ITaskbarList3::Init"), hr);
return;
taskbarList->Release();
return NULL;
}
return new wxTaskBarButtonImpl(taskbarList, parent);
}
wxTaskBarButtonImpl::wxTaskBarButtonImpl(wxITaskbarList3* taskbarList,
wxWindow* parent)
: m_hwnd(parent->GetHandle()),
m_taskbarList(taskbarList),
m_progressRange(0),
m_hasInitThumbnailToolbar(false)
{
}
wxTaskBarButtonImpl::~wxTaskBarButtonImpl()