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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
|
/////////////////////////////////////////////////////////////////////////////////////////
// Miranda NG: the free IM client for Microsoft* Windows*
//
// Copyright (с) 2012-17 Miranda NG project,
// Copyright (c) 2000-09 Miranda ICQ/IM project,
// all portions of this codebase are copyrighted to the people
// listed in contributors.txt.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// you should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
// part of tabSRMM messaging plugin for Miranda.
//
// (C) 2005-2010 by silvercircle _at_ gmail _dot_ com and contributors
//
// - Windows 7 taskbar integration class
// - Proxy window class, needed to support custom aero peek tab
// thumbnails
// - Thumbnail classes to provide task bar thumbnails for Aero peek
// preview.
#ifndef __TASKBAR_H
#define __TASKBAR_H
#define PROXYCLASSNAME L"TabSRMM_DWMProxy"
extern HINSTANCE g_hInst;
class CProxyWindow;
class CThumbBase {
public:
CThumbBase(const CProxyWindow* pWnd);
virtual ~CThumbBase();
__inline const HBITMAP getHBM() const { return m_hbmThumb; }
__inline const bool isValid() const { return m_isValid; }
virtual void setValid(const bool fNewValid) { m_isValid = fNewValid; }
virtual void update() = 0;
protected:
const CTabBaseDlg *m_dat;
const CProxyWindow *m_pWnd;
HBITMAP m_hbmThumb, m_hbmOld;
LONG m_width, m_height;
HDC m_hdc;
RECT m_rc, m_rcTop, m_rcBottom, m_rcIcon;
DWORD m_dtFlags;
SIZE m_sz;
LONG m_cx, m_cy;
HFONT m_hOldFont;
virtual void renderBase();
virtual void renderContent() = 0;
private:
void setupRect();
private:
bool m_isValid;
};
class CThumbIM : public CThumbBase
{
public:
CThumbIM(const CProxyWindow* pWnd);
virtual ~CThumbIM() {};
void update();
private:
virtual void renderContent() override;
};
class CThumbMUC : public CThumbBase
{
SESSION_INFO *si;
public:
CThumbMUC(const CProxyWindow* pWnd, SESSION_INFO*);
virtual ~CThumbMUC() {};
void update();
private:
virtual void renderContent() override;
};
class CProxyWindow
{
public:
CProxyWindow(CTabBaseDlg *dat);
~CProxyWindow();
void updateIcon(const HICON hIcon) const;
void updateTitle(const wchar_t *tszTitle) const;
void setBigIcon(const HICON hIcon, bool fInvalidate = true);
void setOverlayIcon(const HICON hIcon, bool fInvalidate = true);
void activateTab() const;
void Invalidate() const;
void verifyDwmState();
__inline const CTabBaseDlg* getDat() const { return m_dat; }
__inline const LONG getWidth() const { return m_width; }
__inline const LONG getHeight() const { return m_height; }
__inline const HWND getHwnd() const { return m_hwndProxy; }
__inline const HICON getBigIcon() const { return m_hBigIcon; }
__inline const HICON getOverlayIcon() const { return m_hOverlayIcon; }
static LRESULT CALLBACK stubWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
private:
CTabBaseDlg *m_dat;
HWND m_hwndProxy;
LONG m_width, m_height;
HICON m_hBigIcon, m_hOverlayIcon;
LRESULT CALLBACK wndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
void sendThumb(LONG width, LONG height);
void sendPreview();
CThumbBase *m_thumb;
};
class CTaskbarInteract
{
public:
CTaskbarInteract()
{
m_pTaskbarInterface = 0;
m_IconSize = 0;
m_isEnabled = IsWinVer7Plus() ? true : false;
if (m_isEnabled) {
::CoCreateInstance(CLSID_TaskbarList, nullptr, CLSCTX_ALL, IID_ITaskbarList3, (void**)&m_pTaskbarInterface);
updateMetrics();
if (0 == m_pTaskbarInterface)
m_isEnabled = false;
}
/*
* register proxy window class
*/
WNDCLASSEX wcex = { sizeof(wcex) };
wcex.lpfnWndProc = CProxyWindow::stubWndProc;
wcex.hInstance = g_hInst;
wcex.hCursor = LoadCursor(nullptr, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
wcex.lpszClassName = PROXYCLASSNAME;
::RegisterClassEx(&wcex);
}
~CTaskbarInteract()
{
if (m_isEnabled && m_pTaskbarInterface) {
m_pTaskbarInterface->Release();
m_pTaskbarInterface = 0;
m_isEnabled = false;
}
::UnregisterClass(PROXYCLASSNAME, g_hInst);
}
const LONG getIconSize() const { return m_IconSize; }
const bool haveAlwaysGroupingMode() const { return m_fHaveAlwaysGrouping; }
bool setOverlayIcon(HWND hwndDlg, LPARAM lParam) const;
void clearOverlayIcon(HWND hwndDlg) const;
bool haveLargeIcons();
LONG updateMetrics();
void registerTab(const HWND hwndTab, const HWND hwndContainer) const;
void unRegisterTab(const HWND hwndTab) const;
void SetTabActive(const HWND hwndTab, const HWND hwndGroup) const;
//const wchar_t* getFileNameFromWindow (const HWND hWnd);
private:
ITaskbarList3 *m_pTaskbarInterface;
bool m_isEnabled;
bool m_fHaveLargeicons;
bool m_fHaveAlwaysGrouping;
LONG m_IconSize;
};
extern CTaskbarInteract *Win7Taskbar;
#endif /* __TASKBAR_H */
|