-
Notifications
You must be signed in to change notification settings - Fork 19
/
AeroGlass.cpp
513 lines (425 loc) · 19.4 KB
/
AeroGlass.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
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
// sktoolslib - common files for SK tools
// Copyright (C) 2012, 2017, 2020-2021 - Stefan Kueng
// 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,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
#include "stdafx.h"
#include "AeroGlass.h"
#include <VersionHelpers.h>
#include <vssym32.h>
// SDKs prior to Win10 don't have the IsWindows10OrGreater API in the versionhelpers header, so
// we define it here just in case:
#ifndef _WIN32_WINNT_WIN10
# define _WIN32_WINNT_WIN10 0x0A00
# define _WIN32_WINNT_WINTHRESHOLD 0x0A00
# define IsWindows10OrGreater() (IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WIN10), LOBYTE(_WIN32_WINNT_WIN10), 0))
#endif
using DWM_EXTEND_FRAME_INTO_CLIENT_AREA = HRESULT(__stdcall* )(HWND, const MARGINS*);
using DWM_IS_COMPOSITION_ENABLED = HRESULT(__stdcall* )(BOOL* pfEnabled);
using DWM_ENABLE_COMPOSITION = HRESULT(__stdcall* )(UINT uCompositionAction);
CDwmApiImpl::CDwmApiImpl()
: m_hDwmApiLib(nullptr)
{
}
BOOL CDwmApiImpl::Initialize()
{
if (m_hDwmApiLib)
{
SetLastError(ERROR_ALREADY_INITIALIZED);
return FALSE;
}
m_hDwmApiLib = LoadLibraryW(L"dwmapi.dll");
return IsInitialized();
}
BOOL CDwmApiImpl::IsInitialized() const
{
return (nullptr != m_hDwmApiLib);
}
CDwmApiImpl::~CDwmApiImpl()
{
if (IsInitialized())
{
FreeLibrary(m_hDwmApiLib);
m_hDwmApiLib = nullptr;
}
}
HRESULT CDwmApiImpl::DwmExtendFrameIntoClientArea(HWND hWnd, const MARGINS* pMarInset) const
{
if (!IsInitialized())
{
return OLE_E_BLANK;
}
if (!IsDwmCompositionEnabled())
return OLE_E_BLANK;
DWM_EXTEND_FRAME_INTO_CLIENT_AREA pfnDwmExtendFrameIntoClientArea = reinterpret_cast<DWM_EXTEND_FRAME_INTO_CLIENT_AREA>(GetProcAddress(m_hDwmApiLib, "DwmExtendFrameIntoClientArea"));
if (!pfnDwmExtendFrameIntoClientArea)
return HRESULT_FROM_WIN32(GetLastError());
return pfnDwmExtendFrameIntoClientArea(hWnd, pMarInset);
}
BOOL CDwmApiImpl::IsDwmCompositionEnabled() const
{
if (!IsInitialized())
{
SetLastError(static_cast<DWORD>(OLE_E_BLANK));
return FALSE;
}
// disable aero dialogs in high contrast mode and on Windows 10:
// in high contrast mode, while DWM is still active, the aero effect is not
// in Win 10, the dialog title bar is not rendered transparent, so the dialogs would
// look really ugly and not symmetric.
HIGHCONTRAST hc = {sizeof(HIGHCONTRAST)};
SystemParametersInfo(SPI_GETHIGHCONTRAST, sizeof(HIGHCONTRAST), &hc, FALSE);
DWM_IS_COMPOSITION_ENABLED pfnDwmIsCompositionEnabled = reinterpret_cast<DWM_IS_COMPOSITION_ENABLED>(GetProcAddress(m_hDwmApiLib, "DwmIsCompositionEnabled"));
if (!pfnDwmIsCompositionEnabled)
return FALSE;
BOOL bEnabled = FALSE;
HRESULT hRes = pfnDwmIsCompositionEnabled(&bEnabled);
return SUCCEEDED(hRes) && bEnabled && ((hc.dwFlags & HCF_HIGHCONTRASTON) == 0) && !IsWindows10OrGreater();
}
HRESULT CDwmApiImpl::DwmEnableComposition(UINT uCompositionAction) const
{
if (!IsInitialized())
{
SetLastError(static_cast<DWORD>(OLE_E_BLANK));
return S_FALSE;
}
DWM_ENABLE_COMPOSITION pfnDwmEnableComposition = reinterpret_cast<DWM_ENABLE_COMPOSITION>(GetProcAddress(m_hDwmApiLib, "DwmEnableComposition"));
if (!pfnDwmEnableComposition)
return HRESULT_FROM_WIN32(GetLastError());
return pfnDwmEnableComposition(uCompositionAction);
}
CUxThemeAeroImpl::CUxThemeAeroImpl()
: m_hUxThemeLib(nullptr)
{
}
BOOL CUxThemeAeroImpl::Initialize()
{
if (m_hUxThemeLib)
{
SetLastError(ERROR_ALREADY_INITIALIZED);
return FALSE;
}
m_hUxThemeLib = LoadLibraryW(L"uxtheme.dll");
return IsInitialized();
}
using BUFFERED_PAINT_INIT = HRESULT(__stdcall* )();
using OPEN_THEME_DATA = HTHEME(__stdcall* )(HWND hwnd, LPCWSTR pszClassList);
using CLOSE_THEME_DATA = HRESULT(__stdcall* )(HTHEME hTheme);
using BEGIN_BUFFERED_PAINT = HPAINTBUFFER(__stdcall* )(HDC hdcTarget, const RECT* prcTarget, BP_BUFFERFORMAT dwFormat, BP_PAINTPARAMS* pPaintParams, HDC* phdc);
using END_BUFFERED_PAINT = HRESULT(__stdcall* )(HPAINTBUFFER hBufferedPaint, BOOL fUpdateTarget);
using DRAW_THEME_TEXT_EX = HRESULT(__stdcall* )(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, LPCWSTR pszText, int cchText, DWORD dwTextFlags, LPRECT pRect, const DTTOPTS* pOptions);
using GET_THEME_INT = HRESULT(__stdcall* )(HTHEME hTheme, int iPartId, int iStateId, int iPropId, int* piVal);
using GET_THEME_SYS_FONT = HRESULT(__stdcall* )(HTHEME hTheme, int iFontId, LOGFONTW* plf);
using BUFFERED_PAINT_SET_ALPHA = HRESULT(__stdcall* )(HPAINTBUFFER hBufferedPaint, const RECT* prc, BYTE alpha);
using DRAW_THEME_BACKGROUND = HRESULT(__stdcall* )(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT* pRect, const RECT* pClipRect);
using GET_THEME_BKG_CONTENT_RECT = HRESULT(__stdcall* )(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, LPCRECT pBoundingRect, LPRECT pContentRect);
using GET_THEME_BKG_CONTENT_EXTENT = HRESULT(__stdcall* )(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, LPCRECT pContentRect, LPRECT pExtentRect);
using GET_THEME_BITMAP = HRESULT(__stdcall* )(HTHEME hTheme, int iPartId, int iStateId, int iPropId, ULONG dwFlags, HBITMAP* phBitmap);
using DRAW_THEME_PARENT_BACKGROUND = HRESULT(__stdcall* )(HWND hwnd, HDC hdc, const RECT* prc);
using IS_THEME_BACKGROUND_PARTIALLY_TRANSPARENT = BOOL(__stdcall* )(HTHEME hTheme, int iPartId, int iStateId);
using DRAW_THEME_TEXT = HRESULT(__stdcall* )(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, LPCWSTR pszText, int iCharCount, DWORD dwTextFlags, DWORD dwTextFlags2, LPCRECT pRect);
using GET_THEME_COLOR = HRESULT(__stdcall* )(HTHEME hTheme, int iPartId, int iStateId, int iPropId, COLORREF* pColor);
using GET_THEME_PART_SIZE = HRESULT(__stdcall* )(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, LPCRECT prc, THEMESIZE eSize, SIZE* psz);
using GET_THEME_POSITION = HRESULT(__stdcall* )(HTHEME hTheme, int iPartId, int iStateId, int iPropId, POINT* pPoint);
using GET_THEME_MARGINS = HRESULT(__stdcall* )(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, int iPropId, LPRECT prc, MARGINS* pMargins);
using GET_THEME_METRIC = HRESULT(__stdcall* )(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, int iPropId, int* piVal);
using GET_THEME_RECT = HRESULT(__stdcall* )(HTHEME hTheme, int iPartId, int iStateId, int iPropId, LPRECT pRect);
BOOL CUxThemeAeroImpl::IsInitialized() const
{
return (nullptr != m_hUxThemeLib);
}
CUxThemeAeroImpl::~CUxThemeAeroImpl()
{
if (IsInitialized())
{
FreeLibrary(m_hUxThemeLib);
m_hUxThemeLib = nullptr;
}
}
HRESULT CUxThemeAeroImpl::BufferedPaintInit() const
{
if (!IsInitialized())
{
return OLE_E_BLANK;
}
BUFFERED_PAINT_INIT pfnBufferedPaintInit = reinterpret_cast<BUFFERED_PAINT_INIT>(GetProcAddress(m_hUxThemeLib, "BufferedPaintInit"));
if (!pfnBufferedPaintInit)
return HRESULT_FROM_WIN32(GetLastError());
return pfnBufferedPaintInit();
}
HRESULT CUxThemeAeroImpl::BufferedPaintUnInit() const
{
if (!IsInitialized())
{
return OLE_E_BLANK;
}
BUFFERED_PAINT_INIT pfnBufferedPaintUnInit = reinterpret_cast<BUFFERED_PAINT_INIT>(GetProcAddress(m_hUxThemeLib, "BufferedPaintUnInit"));
if (!pfnBufferedPaintUnInit)
return HRESULT_FROM_WIN32(GetLastError());
return pfnBufferedPaintUnInit();
}
HTHEME CUxThemeAeroImpl::OpenThemeData(HWND hwnd, LPCWSTR pszClassList) const
{
if (!IsInitialized())
{
SetLastError(static_cast<DWORD>(OLE_E_BLANK));
return nullptr;
}
OPEN_THEME_DATA pfnOpenThemeData = reinterpret_cast<OPEN_THEME_DATA>(GetProcAddress(m_hUxThemeLib, "OpenThemeData"));
if (!pfnOpenThemeData)
return nullptr;
return pfnOpenThemeData(hwnd, pszClassList);
}
HRESULT CUxThemeAeroImpl::CloseThemeData(HTHEME hTheme) const
{
if (!IsInitialized())
{
return OLE_E_BLANK;
}
CLOSE_THEME_DATA pfnCloseThemeData = reinterpret_cast<CLOSE_THEME_DATA>(GetProcAddress(m_hUxThemeLib, "CloseThemeData"));
if (!pfnCloseThemeData)
return HRESULT_FROM_WIN32(GetLastError());
return pfnCloseThemeData(hTheme);
}
HANDLE CUxThemeAeroImpl::BeginBufferedPaint(HDC hdcTarget, const RECT* prcTarget, BP_BUFFERFORMAT dwFormat, BP_PAINTPARAMS* pPaintParams, HDC* phdc) const
{
if (!IsInitialized())
{
SetLastError(static_cast<DWORD>(OLE_E_BLANK));
return nullptr;
}
BEGIN_BUFFERED_PAINT pfnBeginBufferedPaint = reinterpret_cast<BEGIN_BUFFERED_PAINT>(GetProcAddress(m_hUxThemeLib, "BeginBufferedPaint"));
if (!pfnBeginBufferedPaint)
return nullptr;
return pfnBeginBufferedPaint(hdcTarget, prcTarget, dwFormat, pPaintParams, phdc);
}
HRESULT CUxThemeAeroImpl::EndBufferedPaint(HANDLE hBufferedPaint, BOOL fUpdateTarget) const
{
if (!IsInitialized())
{
return OLE_E_BLANK;
}
END_BUFFERED_PAINT pfnEndBufferedPaint = reinterpret_cast<END_BUFFERED_PAINT>(GetProcAddress(m_hUxThemeLib, "EndBufferedPaint"));
if (!pfnEndBufferedPaint)
return HRESULT_FROM_WIN32(GetLastError());
return pfnEndBufferedPaint(hBufferedPaint, fUpdateTarget);
}
HRESULT CUxThemeAeroImpl::DrawThemeTextEx(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, LPCWSTR pszText, int cchText, DWORD dwTextFlags, LPRECT pRect, const DTTOPTS* pOptions) const
{
if (!IsInitialized())
{
return OLE_E_BLANK;
}
DRAW_THEME_TEXT_EX pfnDrawThemeTextEx = reinterpret_cast<DRAW_THEME_TEXT_EX>(GetProcAddress(m_hUxThemeLib, "DrawThemeTextEx"));
if (!pfnDrawThemeTextEx)
return HRESULT_FROM_WIN32(GetLastError());
return pfnDrawThemeTextEx(hTheme, hdc, iPartId, iStateId, pszText, cchText, dwTextFlags, pRect, pOptions);
}
HRESULT CUxThemeAeroImpl::GetThemeInt(HTHEME hTheme, int iPartId, int iStateId, int iPropId, int* piVal) const
{
if (!IsInitialized())
{
return OLE_E_BLANK;
}
GET_THEME_INT pfnGetThemeInt = reinterpret_cast<GET_THEME_INT>(GetProcAddress(m_hUxThemeLib, "GetThemeInt"));
if (!pfnGetThemeInt)
return HRESULT_FROM_WIN32(GetLastError());
return pfnGetThemeInt(hTheme, iPartId, iStateId, iPropId, piVal);
}
HRESULT CUxThemeAeroImpl::GetThemeSysFont(HTHEME hTheme, int iFontId, LOGFONTW* plf) const
{
if (!IsInitialized())
{
return OLE_E_BLANK;
}
GET_THEME_SYS_FONT pfnGetThemeSysFont = reinterpret_cast<GET_THEME_SYS_FONT>(GetProcAddress(m_hUxThemeLib, "GetThemeSysFont"));
if (!pfnGetThemeSysFont)
return HRESULT_FROM_WIN32(GetLastError());
return pfnGetThemeSysFont(hTheme, iFontId, plf);
}
HRESULT CUxThemeAeroImpl::BufferedPaintSetAlpha(HPAINTBUFFER hBufferedPaint, const RECT* prc, BYTE alpha) const
{
if (!IsInitialized())
{
return OLE_E_BLANK;
}
BUFFERED_PAINT_SET_ALPHA pfnBufferedPaintSetAlpha = reinterpret_cast<BUFFERED_PAINT_SET_ALPHA>(GetProcAddress(m_hUxThemeLib, "BufferedPaintSetAlpha"));
if (!pfnBufferedPaintSetAlpha)
return HRESULT_FROM_WIN32(GetLastError());
return pfnBufferedPaintSetAlpha(hBufferedPaint, prc, alpha);
}
HRESULT CUxThemeAeroImpl::BufferedPaintMakeOpaque_(HPAINTBUFFER hBufferedPaint, const RECT* prc) const
{
return BufferedPaintSetAlpha(hBufferedPaint, prc, 255);
}
HRESULT CUxThemeAeroImpl::DrawThemeBackground(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT* pRect, const RECT* pClipRect) const
{
if (!IsInitialized())
{
return OLE_E_BLANK;
}
DRAW_THEME_BACKGROUND pfnDrawThemeBackground = reinterpret_cast<DRAW_THEME_BACKGROUND>(GetProcAddress(m_hUxThemeLib, "DrawThemeBackground"));
if (!pfnDrawThemeBackground)
return HRESULT_FROM_WIN32(GetLastError());
return pfnDrawThemeBackground(hTheme, hdc, iPartId, iStateId, pRect, pClipRect);
}
HRESULT CUxThemeAeroImpl::GetThemeBackgroundContentRect(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, LPCRECT pBoundingRect, LPRECT pContentRect) const
{
if (!IsInitialized())
{
return OLE_E_BLANK;
}
GET_THEME_BKG_CONTENT_RECT pfnGetThemeBackgroundContentRect = reinterpret_cast<GET_THEME_BKG_CONTENT_RECT>(GetProcAddress(m_hUxThemeLib, "GetThemeBackgroundContentRect"));
if (!pfnGetThemeBackgroundContentRect)
return HRESULT_FROM_WIN32(GetLastError());
return pfnGetThemeBackgroundContentRect(hTheme, hdc, iPartId, iStateId, pBoundingRect, pContentRect);
}
HRESULT CUxThemeAeroImpl::GetThemeBackgroundExtent(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, LPCRECT pContentRect, LPRECT pExtentRect) const
{
if (!IsInitialized())
{
return OLE_E_BLANK;
}
GET_THEME_BKG_CONTENT_EXTENT pfnGetThemeBackgroundExtent = reinterpret_cast<GET_THEME_BKG_CONTENT_EXTENT>(GetProcAddress(m_hUxThemeLib, "GetThemeBackgroundExtent"));
if (!pfnGetThemeBackgroundExtent)
return HRESULT_FROM_WIN32(GetLastError());
return pfnGetThemeBackgroundExtent(hTheme, hdc, iPartId, iStateId, pContentRect, pExtentRect);
}
HRESULT CUxThemeAeroImpl::GetThemeBitmap(HTHEME hTheme, int iPartId, int iStateId, int iPropId, ULONG dwFlags, HBITMAP* phBitmap) const
{
if (!IsInitialized())
{
return OLE_E_BLANK;
}
GET_THEME_BITMAP pfnGetThemeBitmap = reinterpret_cast<GET_THEME_BITMAP>(GetProcAddress(m_hUxThemeLib, "GetThemeBitmap"));
if (!pfnGetThemeBitmap)
return HRESULT_FROM_WIN32(GetLastError());
return pfnGetThemeBitmap(hTheme, iPartId, iStateId, iPropId, dwFlags, phBitmap);
}
BOOL CUxThemeAeroImpl::DetermineGlowSize(int* piSize, LPCWSTR pszClassIdList /*= nullptr*/) const
{
if (!piSize)
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
if (!pszClassIdList)
pszClassIdList = L"CompositedWindow::Window";
HTHEME hThemeWindow = OpenThemeData(nullptr, pszClassIdList);
if (hThemeWindow != nullptr)
{
GetThemeInt(hThemeWindow, 0, 0, TMT_TEXTGLOWSIZE, piSize);
CloseThemeData(hThemeWindow);
return TRUE;
}
SetLastError(ERROR_FILE_NOT_FOUND);
return FALSE;
}
HRESULT CUxThemeAeroImpl::DrawThemeParentBackground(HWND hwnd, HDC hdc, const RECT* prc) const
{
if (!IsInitialized())
{
return OLE_E_BLANK;
}
DRAW_THEME_PARENT_BACKGROUND pfnDrawThemeParentBackground = reinterpret_cast<DRAW_THEME_PARENT_BACKGROUND>(GetProcAddress(m_hUxThemeLib, "DrawThemeParentBackground"));
if (!pfnDrawThemeParentBackground)
return HRESULT_FROM_WIN32(GetLastError());
return pfnDrawThemeParentBackground(hwnd, hdc, prc);
}
BOOL CUxThemeAeroImpl::IsThemeBackgroundPartiallyTransparent(HTHEME hTheme, int iPartId, int iStateId) const
{
if (!IsInitialized())
{
return FALSE;
}
IS_THEME_BACKGROUND_PARTIALLY_TRANSPARENT pfnIsThemeBackgroundPartiallyTransparent = reinterpret_cast<IS_THEME_BACKGROUND_PARTIALLY_TRANSPARENT>(GetProcAddress(m_hUxThemeLib, "IsThemeBackgroundPartiallyTransparent"));
if (!pfnIsThemeBackgroundPartiallyTransparent)
return FALSE;
return pfnIsThemeBackgroundPartiallyTransparent(hTheme, iPartId, iStateId);
}
HRESULT CUxThemeAeroImpl::DrawThemeText(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, LPCWSTR pszText, int iCharCount, DWORD dwTextFlags, DWORD dwTextFlags2, LPCRECT pRect) const
{
if (!IsInitialized())
{
return OLE_E_BLANK;
}
DRAW_THEME_TEXT pfnDrawThemeText = reinterpret_cast<DRAW_THEME_TEXT>(GetProcAddress(m_hUxThemeLib, "DrawThemeText"));
if (!pfnDrawThemeText)
return HRESULT_FROM_WIN32(GetLastError());
return pfnDrawThemeText(hTheme, hdc, iPartId, iStateId, pszText, iCharCount, dwTextFlags, dwTextFlags2, pRect);
}
HRESULT CUxThemeAeroImpl::GetThemeColor(HTHEME hTheme, int iPartId, int iStateId, int iPropId, COLORREF* pColor) const
{
if (!IsInitialized())
{
return OLE_E_BLANK;
}
GET_THEME_COLOR pfnGetThemeColor = reinterpret_cast<GET_THEME_COLOR>(GetProcAddress(m_hUxThemeLib, "GetThemeColor"));
if (!pfnGetThemeColor)
return HRESULT_FROM_WIN32(GetLastError());
return pfnGetThemeColor(hTheme, iPartId, iStateId, iPropId, pColor);
}
HRESULT CUxThemeAeroImpl::GetThemePartSize(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, LPCRECT prc, THEMESIZE eSize, SIZE* psz) const
{
if (!IsInitialized())
{
return OLE_E_BLANK;
}
GET_THEME_PART_SIZE pfnGetThemePartSize = reinterpret_cast<GET_THEME_PART_SIZE>(GetProcAddress(m_hUxThemeLib, "GetThemePartSize"));
if (!pfnGetThemePartSize)
return HRESULT_FROM_WIN32(GetLastError());
return pfnGetThemePartSize(hTheme, hdc, iPartId, iStateId, prc, eSize, psz);
}
HRESULT CUxThemeAeroImpl::GetThemePosition(HTHEME hTheme, int iPartId, int iStateId, int iPropId, POINT* pPoint) const
{
if (!IsInitialized())
{
return OLE_E_BLANK;
}
GET_THEME_POSITION pfnGetThemePosition = reinterpret_cast<GET_THEME_POSITION>(GetProcAddress(m_hUxThemeLib, "GetThemePosition"));
if (!pfnGetThemePosition)
return HRESULT_FROM_WIN32(GetLastError());
return pfnGetThemePosition(hTheme, iPartId, iStateId, iPropId, pPoint);
}
HRESULT CUxThemeAeroImpl::GetThemeMargins(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, int iPropId, LPRECT prc, MARGINS* pMargins) const
{
if (!IsInitialized())
{
return OLE_E_BLANK;
}
GET_THEME_MARGINS pfnGetThemeMargins = reinterpret_cast<GET_THEME_MARGINS>(GetProcAddress(m_hUxThemeLib, "GetThemeMargins"));
if (!pfnGetThemeMargins)
return HRESULT_FROM_WIN32(GetLastError());
return pfnGetThemeMargins(hTheme, hdc, iPartId, iStateId, iPropId, prc, pMargins);
}
HRESULT CUxThemeAeroImpl::GetThemeMetric(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, int iPropId, int* piVal) const
{
if (!IsInitialized())
{
return OLE_E_BLANK;
}
GET_THEME_METRIC pfnGetThemeMetric = reinterpret_cast<GET_THEME_METRIC>(GetProcAddress(m_hUxThemeLib, "GetThemeMetric"));
if (!pfnGetThemeMetric)
return HRESULT_FROM_WIN32(GetLastError());
return pfnGetThemeMetric(hTheme, hdc, iPartId, iStateId, iPropId, piVal);
}
HRESULT CUxThemeAeroImpl::GetThemeRect(HTHEME hTheme, int iPartId, int iStateId, int iPropId, LPRECT pRect) const
{
if (!IsInitialized())
{
return OLE_E_BLANK;
}
GET_THEME_RECT pfnGetThemeRect = reinterpret_cast<GET_THEME_RECT>(GetProcAddress(m_hUxThemeLib, "GetThemeRect"));
if (!pfnGetThemeRect)
return HRESULT_FROM_WIN32(GetLastError());
return pfnGetThemeRect(hTheme, iPartId, iStateId, iPropId, pRect);
}