forked from TheSaw/win7shell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
taskbar.cpp
103 lines (92 loc) · 2.25 KB
/
taskbar.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#include <Windows.h>
#include <ObjBase.h>
#include <dwmapi.h>
#include <fstream>
#include "gen_win7shell.h"
#include "taskbar.h"
#include <loader/loader/utils.h>
iTaskBar::iTaskBar(sSettings& settings) : pTBL(NULL), progressbarstate(TBPF_NOPROGRESS), m_settings(settings)
{
}
iTaskBar::~iTaskBar()
{
if (pTBL != NULL)
{
pTBL->Release();
pTBL = NULL;
}
}
bool iTaskBar::Reset()
{
if (pTBL != NULL)
{
pTBL->Release();
pTBL = NULL;
}
HRESULT hr = CreateCOMInProc(CLSID_TaskbarList, IID_ITaskbarList,
reinterpret_cast<void**>(&pTBL));
if (!SUCCEEDED(hr) || !pTBL)
{
return false;
}
const bool ret = SUCCEEDED(pTBL->HrInit());
SetWindowAttr();
return ret;
}
void iTaskBar::ThumbBarUpdateButtons(std::vector<THUMBBUTTON>& buttons, HIMAGELIST ImageList)
{
if (pTBL != NULL)
{
if (ImageList != NULL)
{
pTBL->ThumbBarSetImageList(plugin.hwndParent, ImageList);
pTBL->ThumbBarAddButtons(plugin.hwndParent, (int)buttons.size(), (LPTHUMBBUTTON)&buttons[0]);
}
else
{
pTBL->ThumbBarUpdateButtons(plugin.hwndParent, (int)buttons.size(), (LPTHUMBBUTTON)&buttons[0]);
}
}
}
void iTaskBar::SetIconOverlay(HICON icon, LPCWSTR text)
{
if (pTBL != NULL)
{
__try
{
pTBL->SetOverlayIcon(plugin.hwndParent, icon, text);
}
__except (EXCEPTION_EXECUTE_HANDLER)
{
}
}
}
void iTaskBar::SetWindowAttr(void) const
{
// if we're under a classic skin & to show the main
// window then we can just let Windows handle it as
// it will do a much better job with less resources
BOOL enabled = (!IsIconic(plugin.hwndParent) ? !(classicSkin &&
(m_settings.Thumbnailbackground == BG_WINAMP)) : /*!classicSkin/*/TRUE/**/);
DwmSetWindowAttribute(plugin.hwndParent, DWMWA_HAS_ICONIC_BITMAP, &enabled, sizeof(enabled));
DwmSetWindowAttribute(plugin.hwndParent, DWMWA_FORCE_ICONIC_REPRESENTATION, &enabled, sizeof(enabled));
DwmInvalidateIconicBitmaps(plugin.hwndParent);
}
void iTaskBar::SetProgressValue(ULONGLONG completed, ULONGLONG total)
{
if (pTBL != NULL)
{
pTBL->SetProgressValue(plugin.hwndParent, completed, total);
}
}
void iTaskBar::SetProgressState(TBPFLAG newstate)
{
if (newstate != progressbarstate)
{
if (pTBL != NULL)
{
pTBL->SetProgressState(plugin.hwndParent, newstate);
}
progressbarstate = newstate;
}
}