-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtaskbar.cpp
78 lines (62 loc) · 1.96 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
#include <Windows.h>
#include <ObjBase.h>
#include <dwmapi.h>
#include <fstream>
#include "taskbar.h"
iTaskBar::iTaskBar() :
mWinampWnd(NULL),
pTBL(NULL),
progressbarstate(TBPF_NOPROGRESS)
{
CoInitialize(0);
}
iTaskBar::~iTaskBar()
{
if (pTBL != NULL)
pTBL->Release();
CoUninitialize();
}
bool iTaskBar::Reset(HWND WinampWnd)
{
mWinampWnd = WinampWnd;
if (pTBL != NULL)
pTBL->Release();
HRESULT hr = ::CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER,
IID_ITaskbarList, reinterpret_cast<void**>(&pTBL) );
if (!SUCCEEDED(hr))
return false;
hr = pTBL->HrInit();
if (!SUCCEEDED(hr))
return false;
return true;
}
HRESULT iTaskBar::SetImageList(HIMAGELIST ImageList)
{
return pTBL->ThumbBarSetImageList(mWinampWnd, ImageList);
}
HRESULT iTaskBar::ThumbBarUpdateButtons( std::vector<THUMBBUTTON>& thbButtons, bool first )
{
if (first)
return pTBL->ThumbBarAddButtons(mWinampWnd, thbButtons.size(), &thbButtons[0]);
else
return pTBL->ThumbBarUpdateButtons(mWinampWnd, thbButtons.size(), &thbButtons[0]);
}
void iTaskBar::SetIconOverlay( HICON icon, std::wstring text )
{
pTBL->SetOverlayIcon(mWinampWnd, icon, text.c_str());
}
void iTaskBar::SetWindowAttr(bool enable, bool flip, bool peek)
{
bool enabled = true;
DwmInvalidateIconicBitmaps(mWinampWnd);
DwmSetWindowAttribute(mWinampWnd, DWMWA_HAS_ICONIC_BITMAP, &enabled, sizeof(int));
DwmSetWindowAttribute(mWinampWnd, DWMWA_FORCE_ICONIC_REPRESENTATION, &enabled, sizeof(int));
enabled = peek;
DwmSetWindowAttribute(mWinampWnd, DWMWA_DISALLOW_PEEK, &peek, sizeof(int));
if (flip)
{
DWMFLIP3DWINDOWPOLICY flip_policy;
flip_policy = flip ? DWMFLIP3D_EXCLUDEBELOW : DWMFLIP3D_DEFAULT;
DwmSetWindowAttribute(mWinampWnd, DWMWA_FLIP3D_POLICY, &flip_policy, sizeof(int));
}
}