1 ///////////////////////////////////////////////////////////////////////////////
2 // LameXP - Audio Encoder Front-End
3 // Copyright (C) 2004-2014 LoRd_MuldeR <MuldeR2@GMX.de>
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"
30 #define WIN32_LEAN_AND_MEAN
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");
56 void WinSevenTaskbar::uninit(void)
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
;
79 void WinSevenTaskbar::createInterface(void)
83 ITaskbarList3
*ptbl
= NULL
;
84 HRESULT hr
= CoCreateInstance(CLSID_TaskbarList
, NULL
, CLSCTX_INPROC_SERVER
, IID_PPV_ARGS(&ptbl
));
88 HRESULT hr2
= ptbl
->HrInit();
92 /*qDebug("ITaskbarList3::HrInit() succeeded.");*/
97 qWarning("ITaskbarList3::HrInit() has failed.");
102 qWarning("ITaskbarList3 could not be created.");
107 bool WinSevenTaskbar::setTaskbarState(QWidget
*window
, WinSevenTaskbarState state
)
113 HRESULT hr
= HRESULT(-1);
117 case WinSevenTaskbarNoState
:
118 hr
= s_ptbl
->SetProgressState(reinterpret_cast<HWND
>(window
->winId()), TBPF_NOPROGRESS
);
120 case WinSevenTaskbarNormalState
:
121 hr
= s_ptbl
->SetProgressState(reinterpret_cast<HWND
>(window
->winId()), TBPF_NORMAL
);
123 case WinSevenTaskbarIndeterminateState
:
124 hr
= s_ptbl
->SetProgressState(reinterpret_cast<HWND
>(window
->winId()), TBPF_INDETERMINATE
);
126 case WinSevenTaskbarErrorState
:
127 hr
= s_ptbl
->SetProgressState(reinterpret_cast<HWND
>(window
->winId()), TBPF_ERROR
);
129 case WinSevenTaskbarPausedState
:
130 hr
= s_ptbl
->SetProgressState(reinterpret_cast<HWND
>(window
->winId()), TBPF_PAUSED
);
134 result
= SUCCEEDED(hr
);
140 void WinSevenTaskbar::setTaskbarProgress(QWidget
*window
, unsigned __int64 currentValue
, unsigned __int64 maximumValue
)
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)
153 s_ptbl
->SetOverlayIcon(window
->winId(), (icon
? icon
->pixmap(16,16).toWinHICON() : NULL
), L
"LameXP");
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__