Updated SoX binary to v14.4.2-Git (2014-10-06), compiled with ICL 15.0 and MSVC 12.0.
[LameXP.git] / src / WinSevenTaskbar.cpp
blobde533eafae69fbf80f16bb1285ee5b3b85610e93
1 ///////////////////////////////////////////////////////////////////////////////
2 // LameXP - Audio Encoder Front-End
3 // Copyright (C) 2004-2014 LoRd_MuldeR <MuldeR2@GMX.de>
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version, but always including the *additional*
9 // restrictions defined in the "License.txt" file.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this program; if not, write to the Free Software Foundation, Inc.,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 // http://www.gnu.org/licenses/gpl-2.0.txt
21 ///////////////////////////////////////////////////////////////////////////////
23 #include "WinSevenTaskbar.h"
25 #include <QWidget>
26 #include <QIcon>
28 //Windows includes
29 #define NOMINMAX
30 #define WIN32_LEAN_AND_MEAN
31 #include <Windows.h>
32 #include <ShObjIdl.h>
34 static UINT s_winMsg = 0;
35 static ITaskbarList3 *s_ptbl = NULL;
37 WinSevenTaskbar::WinSevenTaskbar(void)
39 THROW("Cannot create instance of this class!");
42 WinSevenTaskbar::~WinSevenTaskbar(void)
46 ////////////////////////////////////////////////////////////
48 #ifdef __ITaskbarList3_INTERFACE_DEFINED__
50 void WinSevenTaskbar::init(void)
52 s_winMsg = RegisterWindowMessageW(L"TaskbarButtonCreated");
53 s_ptbl = NULL;
56 void WinSevenTaskbar::uninit(void)
58 if(s_ptbl)
60 s_ptbl->Release();
61 s_ptbl = NULL;
65 bool WinSevenTaskbar::handleWinEvent(void *message, long *result)
67 bool stopEvent = false;
69 if(((MSG*)message)->message == s_winMsg)
71 if(!s_ptbl) createInterface();
72 *result = (s_ptbl) ? S_OK : S_FALSE;
73 stopEvent = true;
76 return stopEvent;
79 void WinSevenTaskbar::createInterface(void)
81 if(!s_ptbl)
83 ITaskbarList3 *ptbl = NULL;
84 HRESULT hr = CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&ptbl));
86 if (SUCCEEDED(hr))
88 HRESULT hr2 = ptbl->HrInit();
89 if(SUCCEEDED(hr2))
91 s_ptbl = ptbl;
92 /*qDebug("ITaskbarList3::HrInit() succeeded.");*/
94 else
96 ptbl->Release();
97 qWarning("ITaskbarList3::HrInit() has failed.");
100 else
102 qWarning("ITaskbarList3 could not be created.");
107 bool WinSevenTaskbar::setTaskbarState(QWidget *window, WinSevenTaskbarState state)
109 bool result = false;
111 if(s_ptbl && window)
113 HRESULT hr = HRESULT(-1);
115 switch(state)
117 case WinSevenTaskbarNoState:
118 hr = s_ptbl->SetProgressState(reinterpret_cast<HWND>(window->winId()), TBPF_NOPROGRESS);
119 break;
120 case WinSevenTaskbarNormalState:
121 hr = s_ptbl->SetProgressState(reinterpret_cast<HWND>(window->winId()), TBPF_NORMAL);
122 break;
123 case WinSevenTaskbarIndeterminateState:
124 hr = s_ptbl->SetProgressState(reinterpret_cast<HWND>(window->winId()), TBPF_INDETERMINATE);
125 break;
126 case WinSevenTaskbarErrorState:
127 hr = s_ptbl->SetProgressState(reinterpret_cast<HWND>(window->winId()), TBPF_ERROR);
128 break;
129 case WinSevenTaskbarPausedState:
130 hr = s_ptbl->SetProgressState(reinterpret_cast<HWND>(window->winId()), TBPF_PAUSED);
131 break;
134 result = SUCCEEDED(hr);
137 return result;
140 void WinSevenTaskbar::setTaskbarProgress(QWidget *window, unsigned __int64 currentValue, unsigned __int64 maximumValue)
142 if(s_ptbl && window)
144 s_ptbl->SetProgressValue(reinterpret_cast<HWND>(window->winId()), currentValue, maximumValue);
148 void WinSevenTaskbar::setOverlayIcon(QWidget *window, QIcon *icon)
150 #if QT_VERSION < QT_VERSION_CHECK(5,0,0)
151 if(s_ptbl && window)
153 s_ptbl->SetOverlayIcon(window->winId(), (icon ? icon->pixmap(16,16).toWinHICON() : NULL), L"LameXP");
155 #endif
158 #else //__ITaskbarList3_INTERFACE_DEFINED__
160 LAMEXP_COMPILER_WARNING("ITaskbarList3 not defined. Compiling *without* support for Win7 taskbar!")
161 void WinSevenTaskbar::init(void) {}
162 void WinSevenTaskbar::uninit(void) {}
163 bool WinSevenTaskbar::handleWinEvent(MSG *message, long *result) { return false; }
164 void WinSevenTaskbar::createInterface(void) {}
165 bool WinSevenTaskbar::setTaskbarState(QWidget *window, WinSevenTaskbarState state) { return false; }
166 void WinSevenTaskbar::setTaskbarProgress(QWidget *window, unsigned __int64 currentValue, unsigned __int64 maximumValue) {}
167 void WinSevenTaskbar::setOverlayIcon(QWidget *window, QIcon *icon) {}
169 #endif //__ITaskbarList3_INTERFACE_DEFINED__