Repository navigation
Expand file tree
/
Copy pathNBCTranslucentWindows.cpp
More file actions
5341 lines (4729 loc) · 204 KB
/
Copy pathNBCTranslucentWindows.cpp
File metadata and controls
5341 lines (4729 loc) · 204 KB
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
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// ==WindhawkMod==
// @id nbc-translucent-windows
// @name 亚克力窗口
// @description 为你的 windows 11 窗口主题加点料
// @version 1.6.3
// @author Ni But Crazy
// @github https://github.com/Undisputed00x
// @include *
// @compilerOptions -ldwmapi -luxtheme -lcomctl32 -lgdi32 -ld2d1 -lmsimg32 -lshcore
// ==/WindhawkMod==
// ==WindhawkModReadme==
/*
改良版
*/
// ==/WindhawkModReadme==
// ==WindhawkModSettings==
/*
- RenderingMod:
- ThemeBackground: FALSE
$name: Windows 主题自定义渲染
$description: >-
使用 Direct2D 图形应用程序接口修改 Windows 主题的部分内容
- AccentColorControls: FALSE
$name: Windows 主题调色器
$description: >-
为 Windows 主题部分涂上强调色(需要 Windows 主题自定义渲染)
- TextAlphaBlend: FALSE
$name: 文字的透明度混合
$description: >-
对 Windows GDI 文本渲染进行 Alpha 混合
$name: 自定义渲染
- type: none
$name: 效果
$description: >-
要使用 SystemBackdrop 效果,需要 Windows 11 版本 ≥ 22621.xxx(22H2)
$options:
- none: Default
- acrylicblur: Blur (AccentBlurBehind)
- acrylicsystem: Acrylic (SystemBackdrop)
- mica: Mica (SystemBackdrop)
- mica_tabbed: MicaAlt (SystemBackdrop)
- AccentBlurBehind: "00000000"
$name: AccentBlurBehind 背景虚化的颜色混合
$description: >-
将颜色与模糊后的背景进行混合
颜色使用十六进制 ARGB 格式表示,例如 0F000000
- ImmersiveDarkTitle: FALSE
$name: 自动切换深色模式标题栏(监听型)
$description: >-
正常来讲,一个新打开的应用会自行匹配深色模式标题栏,但像是explorer这种只打开新窗口而不重新启动的应用只能使用监听模式了
- ExtendFrame: FALSE
$name: 将效果扩展到整个窗口
$description: >-
使用 DwmExtendFrameIntoClientArea 将效果扩展到整个窗口背景
- CornerOption: default
$name: 窗口角类型
$description: >-
指定窗口的圆角偏好设置
需要 Windows 11 版本 ≥ 22000.xxx(21H2)
$options:
- default: Default
- notrounded: 无圆角
- smallround: win11 圆角
- RainbowSpeed: 1
$name: 彩虹速度
$description: 调整彩虹颜色的刷新速度(取值范围 1 到 100)
- TitlebarColor:
- ColorTitlebar: FALSE
$name: 开启
- RainbowTitlebar: FALSE
$name: 彩虹标题栏
$description: 启用窗口标题栏的彩虹效果
- titlerbarstyles_active: "FF0000"
$name: 聚焦窗口颜色
$description: >-
以十六进制 RGB 格式表示的颜色,例如红色 = FF0000
SystemAccentColor = 2
- titlerbarstyles_inactive: "00FFFF"
$name: 未聚焦窗口颜色
$description: >-
以十六进制 RGB 格式表示的颜色,例如红色 = FF0000
SystemAccentColor = 2
$name: 标题栏颜色
$description: 需要 Windows 11 版本 ≥ 22000.xxx(21H2),此设置将覆盖效果设置。
- TitlebarTextColor:
- ColorTitlebarText: FALSE
$name: 开启
- RainbowTextColor: FALSE
$name: 彩虹标题栏文本颜色
$description: 启用窗口标题栏文字的彩虹效果
- titlerbarcolorstyles_active: "FF0000"
$name: 聚焦窗口颜色
$description: >-
以十六进制 RGB 格式表示的颜色,例如红色 = FF0000
Default = 1
SystemAccentColor = 2
- titlerbarcolorstyles_inactive: "00FFFF"
$name: 未聚焦窗口颜色
$description: >-
以十六进制 RGB 格式表示的颜色,例如红色 = FF0000
Default = 1
SystemAccentColor = 2
$name: 彩虹标题栏文本颜色
$description: >-
需要 Windows 11 版本 ≥ 22000.xxx(21H2)。
注意:此设置仅影响传统 Win32 窗口。由于在 Windows 11 22H2 中,文件资源管理器的标题栏文字渲染方式已改为使用 DirectWrite API,因此要修改文件资源管理器标题栏的文字颜色,请使用 Windhawk 的 File Explorer Styler 模块
- BorderColor:
- ColorBorder: FALSE
$name: 开启
- RainbowBorder: FALSE
$name: 彩虹边框
$description: 启用窗口边框的彩虹效果
- borderstyles_active: "FF0000"
$name: 聚焦窗口颜色
$description: >-
以十六进制 RGB 格式表示的颜色,例如红色 = FF0000
Transparent = 0
Default = 1
SystemAccentColor = 2
- borderstyles_inactive: "00FFFF"
$name: 未聚焦窗口颜色
$description: >-
以十六进制 RGB 格式表示的颜色,例如红色 = FF0000
Transparent = 0
Default = 1
SystemAccentColor = 2
- MenuBorderColor: FALSE
$name: 将彩色边框效果扩展到经典右键菜单
$description: 启用此选项可在 Windows 经典右键菜单中显示彩色边框
$name: 边框颜色
$description: >-
需要 Windows 11 版本 ≥ 22000.xxx(21H2)
- RuledPrograms:
- - target: "mspaint.exe"
$name: 进程
$description: >-
条目可以是进程名称或路径,例如
mspaint.exe
C:\Windows\System32\notepad.exe
- type: none
$name: 效果
$description: >-
SystemBackdrop 效果需要 Windows 11 版本 ≥ 22621.xxx(22H2)
$options:
- none: Default
- acrylicblur: Blur (AccentBlurBehind)
- acrylicsystem: Acrylic (SystemBackdrop)
- mica: Mica (SystemBackdrop)
- mica_tabbed: MicaAlt (SystemBackdrop)
- AccentBlurBehind: "00000000"
$name: AccentBlurBehind 背景虚化的颜色混合
$description: >-
将颜色与模糊后的背景进行混合
颜色使用十六进制 ARGB 格式表示,例如 0F000000
- ImmersiveDarkTitle: FALSE
$name: 自动切换深色模式标题栏(监听型)
$description: >-
正常来讲,一个新打开的应用会自行匹配深色模式标题栏,但像是explorer这种只打开新窗口而不重新启动的应用只能使用监听模式了
- ExtendFrame: FALSE
$name: 将效果扩展到整个窗口
$description: >-
使用 DwmExtendFrameIntoClientArea 将效果扩展到整个窗口背景
- CornerOption: default
$name: 窗口角类型
$description: >-
指定窗口的圆角偏好设置
需要 Windows 11 版本 ≥ 22000.xxx(21H2)
$options:
- default: Default
- notrounded: 无圆角
- smallround: win11 圆角
- RainbowSpeed: 1
$name: 彩虹速度
$description: 调整彩虹颜色的刷新速度(取值范围 1 到 100)
- TitlebarColor:
- ColorTitlebar: FALSE
$name: 开启
- RainbowTitlebar: FALSE
$name: 彩虹标题栏
$description: 启用窗口标题栏的彩虹效果
- titlerbarstyles_active: "FF0000"
$name: 聚焦窗口颜色
$description: >-
以十六进制 RGB 格式表示的颜色,例如红色 = FF0000
SystemAccentColor = 2
- titlerbarstyles_inactive: "00FFFF"
$name: 未聚焦窗口颜色
$description: >-
以十六进制 RGB 格式表示的颜色,例如红色 = FF0000
SystemAccentColor = 2
$name: 标题栏颜色
$description: 需要 Windows 11 版本 ≥ 22000.xxx(21H2),此设置将覆盖效果设置
- TitlebarTextColor:
- ColorTitlebarText: FALSE
$name: 开启
- RainbowTextColor: FALSE
$name: 彩虹标题栏文本颜色
$description: 启用窗口标题栏文字的彩虹效果
- titlerbarcolorstyles_active: "FF0000"
$name: 聚焦窗口颜色
$description: >-
以十六进制 RGB 格式表示的颜色,例如红色 = FF0000
Default = 1
SystemAccentColor = 2
- titlerbarcolorstyles_inactive: "00FFFF"
$name: 未聚焦窗口颜色
$description: >-
以十六进制 RGB 格式表示的颜色,例如红色 = FF0000
Default = 1
SystemAccentColor = 2
$name: 彩虹标题栏文本颜色
$description: >-
需要 Windows 11 版本 ≥ 22000.xxx(21H2)。
注意:此设置仅影响传统 Win32 窗口。由于在 Windows 11 22H2 中,文件资源管理器的标题栏文字渲染方式已改为使用 DirectWrite API,因此要修改文件资源管理器标题栏的文字颜色,请使用 Windhawk 的 File Explorer Styler 模块
- BorderColor:
- ColorBorder: FALSE
$name: 开启
- RainbowBorder: FALSE
$name: 彩虹边框
$description: 启用窗口边框的彩虹效果
- borderstyles_active: "FF0000"
$name: 聚焦窗口颜色
$description: >-
以十六进制 RGB 格式表示的颜色,例如红色 = FF0000
Transparent = 0
Default = 1
SystemAccentColor = 2
- borderstyles_inactive: "00FFFF"
$name: 未聚焦窗口颜色
$description: >-
以十六进制 RGB 格式表示的颜色,例如红色 = FF0000
Transparent = 0
Default = 1
SystemAccentColor = 2
$name: 边框颜色
$description: >-
需要 Windows 11 版本 ≥ 22000.xxx(21H2)
$name: 进程规则
$description: >-
为每个指定的进程添加规则
*/
// ==/WindhawkModSettings==
#include <windhawk_utils.h>
#include <dwmapi.h>
#include <vssym32.h>
#include <uxtheme.h>
#include <random>
#include <string>
#include <array>
#include <mutex>
#include <unordered_set>
#include <d2d1.h>
#include <wrl.h>
#include <ShellScalingApi.h>
static UINT ENABLE = 1;
static constexpr UINT AUTO = 0; // DWMSBT_AUTO
//static constexpr UINT NONE = 1; // DWMSBT_NONE
static constexpr UINT MAINWINDOW = 2; // DWMSBT_MAINWINDOW
static constexpr UINT TRANSIENTWINDOW = 3; // DWMSBT_TRANSIENTWINDOW
static constexpr UINT TABBEDWINDOW = 4; // DWMSBT_TABBEDWINDOW
static constexpr UINT DEFAULT = 0; // DWMWCP_DEFAULT
static constexpr UINT DONTROUND = 1; // DWMWCP_DONOTROUND
static constexpr UINT SMALLROUND = 2; // DWMWCP_ROUNDSMALL
// Get DPI value from the primary monitor without dependance to DPI-aware API
// TODO: Get DPI per window monitor
UINT GetDpiFromMonitor()
{
// Get monitor handle without the need of a window handle
HMONITOR hPrimary = MonitorFromPoint({0, 0}, MONITOR_DEFAULTTOPRIMARY);
UINT dpiX = USER_DEFAULT_SCREEN_DPI, dpiY = USER_DEFAULT_SCREEN_DPI;
if (SUCCEEDED(GetDpiForMonitor(hPrimary, MDT_EFFECTIVE_DPI, &dpiX, &dpiY)))
return dpiY;
return USER_DEFAULT_SCREEN_DPI;
}
UINT g_Dpi = GetDpiFromMonitor();
UINT g_msgRainbowTimer = RegisterWindowMessage(L"Rainbow_effect");
enum {
RAINBOW_LOAD,
RAINBOW_UNLOAD
};
std::wstring g_RainbowPropStr = L"Windhawk_TranslucentMod_Rainbow";
std::mutex g_rainbowWindowsMutex;
std::unordered_set<HWND> g_rainbowWindows;
thread_local BOOL g_DrawTextWithGlowEntry;
typedef HRESULT(WINAPI* pDrawTextWithGlow)(HDC, LPCWSTR, UINT, const RECT*, DWORD, COLORREF, COLORREF, UINT, UINT, BOOL, DTT_CALLBACK_PROC, LPARAM);
static auto DrawTextWithGlow = (pDrawTextWithGlow)GetProcAddress(GetModuleHandle(L"uxtheme.dll"), MAKEINTRESOURCEA(126));
// Detect system dark/light theme mode
//typedef HRESULT(WINAPI* pShouldSystemUseDarkMode)();
//static auto ShouldSystemUseDarkMode = (pShouldSystemUseDarkMode)GetProcAddress(GetModuleHandle(L"uxtheme.dll"), MAKEINTRESOURCEA(138));
thread_local HHOOK g_callWndProcHook;
std::mutex g_allCallWndProcHooksMutex;
std::unordered_set<HHOOK> g_allCallWndProcHooks;
using PUNICODE_STRING = PVOID;
struct Settings{
BOOL FillBg = FALSE;
BOOL AccentColorize = FALSE;
COLORREF AccentColor = 0xFFFFFFFF;
BOOL TextAlphaBlend = FALSE;
COLORREF AccentBlurBehindClr = 0x00000000;
BOOL ImmersiveDarkmode = TRUE;
BOOL ExtendFrame = FALSE;
BOOL AutoImmersiveDark = FALSE;
BOOL Unload = FALSE;
BOOL TitlebarFlag = FALSE;
BOOL CaptionTextFlag = FALSE;
BOOL BorderFlag = FALSE;
BOOL MenuBorderFlag = FALSE;
COLORREF TitlebarActiveColor = DWMWA_COLOR_DEFAULT;
COLORREF CaptionActiveTextColor = DWMWA_COLOR_DEFAULT;
COLORREF BorderActiveColor = DWMWA_COLOR_DEFAULT;
COLORREF g_TitlebarColor = DWMWA_COLOR_DEFAULT;
COLORREF g_CaptionColor = DWMWA_COLOR_DEFAULT;
COLORREF g_BorderColor = DWMWA_COLOR_DEFAULT;
COLORREF TitlebarInactiveColor = DWMWA_COLOR_DEFAULT;
COLORREF CaptionInactiveTextColor = DWMWA_COLOR_DEFAULT;
COLORREF BorderInactiveColor = DWMWA_COLOR_DEFAULT;
FLOAT RainbowSpeed = 1.0f;
BOOL TitlebarRainbowFlag = FALSE;
BOOL CaptionRainbowFlag = FALSE;
BOOL BorderRainbowFlag = FALSE;
enum BACKGROUNDTYPE
{
Default,
AccentBlurBehind,
AcrylicSystemBackdrop,
Mica,
MicaAlt,
} BgType = Default;
enum CORNERTYPE
{
DefaultRounded,
NotRounded,
SmallRounded = 3
} CornerPref = DefaultRounded;
} g_settings;
struct ACCENT_POLICY
{
INT AccentState;
INT AccentFlags;
INT GradientColor;
INT AnimationId;
};
enum ACCENT_STATE
{
ACCENT_STATE_DISABLED,
ACCENT_STATE_ENABLE_GRADIENT,
ACCENT_STATE_ENABLE_TRANSPARENTGRADIENT,
ACCENT_STATE_ENABLE_BLURBEHIND, // Removed in Windows 11 22H2+
ACCENT_STATE_ENABLE_ACRYLICBLURBEHIND,
ACCENT_STATE_ENABLE_HOSTBACKDROP,
ACCENT_STATE_INVALID_STATE
};
enum ACCENT_FLAG
{
ACCENT_FLAG_NONE,
ACCENT_FLAG_ENABLE_MODERN_ACRYLIC_RECIPE = 1 << 1, // Windows 11 22H2+
ACCENT_FLAG_ENABLE_GRADIENT_COLOR = 1 << 1, // ACCENT_ENABLE_BLURBEHIND
ACCENT_FLAG_ENABLE_FULLSCREEN = 1 << 2,
ACCENT_FLAG_ENABLE_BORDER_LEFT = 1 << 5,
ACCENT_FLAG_ENABLE_BORDER_TOP = 1 << 6,
ACCENT_FLAG_ENABLE_BORDER_RIGHT = 1 << 7,
ACCENT_FLAG_ENABLE_BORDER_BOTTOM = 1 << 8,
ACCENT_FLAG_ENABLE_BLUR_RECT = 1 << 9, // DwmpUpdateAccentBlurRect, it is conflicted with ACCENT_ENABLE_GRADIENT_COLOR when using ACCENT_ENABLE_BLURBEHIND
ACCENT_FLAG_ENABLE_BORDER = ACCENT_FLAG_ENABLE_BORDER_LEFT | ACCENT_FLAG_ENABLE_BORDER_TOP
| ACCENT_FLAG_ENABLE_BORDER_RIGHT | ACCENT_FLAG_ENABLE_BORDER_BOTTOM
};
struct WINCOMPATTRDATA
{
DWORD Attrib;
PVOID pvData;
SIZE_T cbData;
};
enum WINDOWCOMPOSITIONATTRIB
{
WCA_UNDEFINED,
WCA_NCRENDERING_ENABLED,
WCA_NCRENDERING_POLICY,
WCA_TRANSITIONS_FORCEDISABLED,
WCA_ALLOW_NCPAINT,
WCA_CAPTION_BUTTON_BOUNDS,
WCA_NONCLIENT_RTL_LAYOUT,
WCA_FORCE_ICONIC_REPRESENTATION,
WCA_EXTENDED_FRAME_BOUNDS,
WCA_HAS_ICONIC_BITMAP,
WCA_THEME_ATTRIBUTES,
WCA_NCRENDERING_EXILED,
WCA_NCADORNMENTINFO,
WCA_EXCLUDED_FROM_LIVEPREVIEW,
WCA_VIDEO_OVERLAY_ACTIVE,
WCA_FORCE_ACTIVEWINDOW_APPEARANCE,
WCA_DISALLOW_PEEK,
WCA_CLOAK,
WCA_CLOAKED,
WCA_ACCENT_POLICY,
WCA_FREEZE_REPRESENTATION,
WCA_EVER_UNCLOAKED,
WCA_VISUAL_OWNER,
WCA_HOLOGRAPHIC,
WCA_EXCLUDED_FROM_DDA,
WCA_PASSIVEUPDATEMODE,
WCA_USEDARKMODECOLORS,
WCA_CORNER_STYLE,
WCA_PART_COLOR,
WCA_DISABLE_MOVESIZE_FEEDBACK,
WCA_LAST
};
ACCENT_POLICY accent = {};
WINCOMPATTRDATA attrib = {};
DWM_BLURBEHIND bb = { 0 };
ID2D1Factory* g_d2dFactory = nullptr;
VOID InitDirect2D()
{
if (!g_d2dFactory)
{
D2D1_FACTORY_OPTIONS options = {};
D2D1CreateFactory(D2D1_FACTORY_TYPE_MULTI_THREADED, options, &g_d2dFactory);
}
}
// Credits to @m417z
DOUBLE g_recipCyclesPerSecond;
VOID TimerInitialize() {
LARGE_INTEGER freq;
QueryPerformanceFrequency(&freq);
DOUBLE cyclesPerSecond = static_cast<DOUBLE>(freq.QuadPart);
g_recipCyclesPerSecond = 1.0 / cyclesPerSecond;
}
DOUBLE TimerGetCycles() {
LARGE_INTEGER T1;
QueryPerformanceCounter(&T1);
return static_cast<DOUBLE>(T1.QuadPart);
}
DOUBLE TimerGetSeconds() {
return TimerGetCycles() * g_recipCyclesPerSecond;
}
using NtUserCreateWindowEx_t = HWND(WINAPI*)(DWORD, PUNICODE_STRING, LPCWSTR, PUNICODE_STRING, DWORD, LONG, LONG, LONG, LONG, HWND, HMENU, HINSTANCE, LPVOID, DWORD, DWORD, DWORD, VOID*);
NtUserCreateWindowEx_t NtUserCreateWindowEx_Original;
static decltype(&DwmExtendFrameIntoClientArea) DwmExtendFrameIntoClientArea_orig = nullptr;
static decltype(&DwmSetWindowAttribute) DwmSetWindowAttribute_orig = nullptr;
static decltype(&DrawTextW) DrawTextW_orig = nullptr;
static decltype(&ExtTextOutW) ExtTextOutW_orig = nullptr;
static decltype(&DrawThemeText) DrawThemeText_orig = nullptr;
static decltype(&DrawThemeTextEx) DrawThemeTextEx_orig = nullptr;
static decltype(&GetThemeBitmap) GetThemeBitmap_orig = nullptr;
static decltype(&GetThemeColor) GetThemeColor_orig = nullptr;
static decltype(&DrawThemeBackground) DrawThemeBackground_orig = nullptr;
static decltype(&DrawThemeBackgroundEx) DrawThemeBackgroundEx_orig = nullptr;
static decltype(&DefWindowProcW) DefWindowProc_orig = nullptr;
VOID NewWindowShown(HWND);
BOOL IsWindowClass(HWND hWnd, LPCWSTR ClassName)
{
WCHAR ClassNameBuffer[256];
GetClassNameW(hWnd, ClassNameBuffer, sizeof(ClassNameBuffer));
if(!wcscmp(ClassName, ClassNameBuffer))
return TRUE;
return FALSE;
}
BOOL IsSystemDarkMode() {
DWORD value = 1; // 默认浅色
HKEY hKey;
if (RegOpenKeyExW(HKEY_CURRENT_USER,
L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize",
0, KEY_READ, &hKey) == ERROR_SUCCESS) {
DWORD size = sizeof(value);
RegQueryValueExW(hKey, L"SystemUsesLightTheme", nullptr, nullptr,
reinterpret_cast<LPBYTE>(&value), &size);
RegCloseKey(hKey);
}
return value == 0; // 0=深色模式
}
BOOL IsWindowEligible(HWND hWnd)
{
LONG_PTR styleEx = GetWindowLongPtrW(hWnd, GWL_EXSTYLE);
LONG_PTR style = GetWindowLongPtrW(hWnd, GWL_STYLE);
// Fixes Snipping Tool rec
if ((styleEx & WS_EX_NOACTIVATE) || (styleEx & WS_EX_TRANSPARENT))
return FALSE;
HWND hParentWnd = GetAncestor(hWnd, GA_PARENT);
if (hParentWnd && hParentWnd != GetDesktopWindow())
return FALSE;
BOOL hasTitleBar = (style & WS_BORDER) && (style & WS_DLGFRAME);
if (!hasTitleBar && ((styleEx & WS_EX_TOOLWINDOW) ||
(style & WS_POPUP) || (styleEx & WS_EX_APPWINDOW)))
return FALSE;
// Don't block CEF apps
if (!((IsWindowClass(hWnd, L"Chrome_WidgetWin_1") || IsWindowClass(hWnd, L"Chrome_WidgetWin_0")) || style & WS_POPUP || styleEx & WS_EX_APPWINDOW || styleEx & WS_EX_DLGMODALFRAME)
&& !(style & WS_THICKFRAME || style & WS_MINIMIZEBOX || style & WS_MAXIMIZEBOX || style & 0x00000080l)) // Firefox dialog
return FALSE;
return TRUE;
}
enum AccentColorShade
{
SystemAccentColorLight3,
SystemAccentColorLight2,
SystemAccentColorLight1,
SystemAccentColorBase,
SystemAccentColorDark1,
SystemAccentColorDark2,
SystemAccentColorDark3,
Unused,
AccentColorCount
};
class AccentPalette
{
public:
std::array<COLORREF, AccentColorCount> Colors;
BOOL LoadAccentPalette();
AccentPalette()
{
LoadAccentPalette();
}
};
AccentPalette g_AccentPalette;
BOOL AccentPalette::LoadAccentPalette()
{
const LPCWSTR kAccentRegPath = L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Accent";
const LPCWSTR kAccentPaletteValue = L"AccentPalette";
HKEY hKey;
if (RegOpenKeyExW(HKEY_CURRENT_USER, kAccentRegPath, 0, KEY_READ, &hKey) != ERROR_SUCCESS)
return false;
BYTE data[32] = {};
DWORD dataSize = sizeof(data);
DWORD type = 0;
if (RegQueryValueExW(hKey, kAccentPaletteValue, nullptr, &type, data, &dataSize) != ERROR_SUCCESS || type != REG_BINARY || dataSize < AccentColorCount * 4)
{
RegCloseKey(hKey);
return false;
}
RegCloseKey(hKey);
for (int i = 0; i < AccentColorCount; ++i)
{
DWORD color = *reinterpret_cast<DWORD*>(&data[i * 4]);
Colors[i] = color;
}
return true;
}
BOOL GetAccentColor(COLORREF& outColor)
{
// In some programs, e.g. snippingtool.exe, the default blue accent color is used instead of the Windows theme with DwmGetColorizationColor.
// Use the immersive color API if available, fall back to DwmGetColorizationColor
// https://github.com/ALTaleX531/TranslucentFlyouts/blob/017970cbac7b77758ab6217628912a8d551fcf7c/Common/ThemeHelper.hpp#L278
static const auto s_GetImmersiveColorFromColorSetEx{ reinterpret_cast<DWORD(WINAPI*)(DWORD dwImmersiveColorSet, DWORD dwImmersiveColorType, BOOL bIgnoreHighContrast, DWORD dwHighContrastCacheMode)>(GetProcAddress(GetModuleHandleW(L"UxTheme.dll"), MAKEINTRESOURCEA(95))) };
static const auto s_GetImmersiveColorTypeFromName{ reinterpret_cast<DWORD(WINAPI*)(LPCWSTR name)>(GetProcAddress(GetModuleHandleW(L"UxTheme.dll"), MAKEINTRESOURCEA(96))) };
static const auto s_GetImmersiveUserColorSetPreference{ reinterpret_cast<DWORD(WINAPI*)(BOOL bForceCheckRegistry, BOOL bSkipCheckOnFail)>(GetProcAddress(GetModuleHandleW(L"UxTheme.dll"), MAKEINTRESOURCEA(98))) };
COLORREF AccentClr{ 0 };
BOOL opaque = FALSE;
if (s_GetImmersiveColorFromColorSetEx && s_GetImmersiveColorTypeFromName && s_GetImmersiveUserColorSetPreference)
{
AccentClr = s_GetImmersiveColorFromColorSetEx(
s_GetImmersiveUserColorSetPreference(FALSE, FALSE),
s_GetImmersiveColorTypeFromName(L"ImmersiveStartHoverBackground"),
TRUE,
0
);
outColor = RGB((AccentClr & 0xFF), (AccentClr >> 8) & 0xFF, (AccentClr >> 16) & 0xFF);
return TRUE;
}
else if (SUCCEEDED(DwmGetColorizationColor(&AccentClr, &opaque)))
{
outColor = RGB((AccentClr >> 16) & 0xFF, (AccentClr >> 8) & 0xFF, AccentClr & 0xFF);
return TRUE;
}
else
{
outColor = DWMWA_COLOR_DEFAULT;
return FALSE;
}
}
D2D1_COLOR_F MyD2D1Color(BYTE A, BYTE R, BYTE G, BYTE B)
{
return D2D1_COLOR_F{
static_cast<FLOAT>(R) / 255.0f,
static_cast<FLOAT>(G) / 255.0f,
static_cast<FLOAT>(B) / 255.0f,
static_cast<FLOAT>(A) / 255.0f
};
}
D2D1_COLOR_F MyD2D1Color(BYTE R, BYTE G, BYTE B)
{
return MyD2D1Color(255, R, G, B);
}
D2D1_COLOR_F IsAccentColorPossibleD2D(BYTE A, BYTE R, BYTE G, BYTE B, AccentColorShade AccentShade = SystemAccentColorBase)
{
if (g_settings.AccentColorize)
{
// Change light/dark accent shades to dark/light depending theme dark mode
/* if (ShouldSystemUseDarkMode() && AccentShade > 3)
AccentShade = static_cast<AccentColorShade>(6 - AccentShade);
else if (!ShouldSystemUseDarkMode() && AccentShade < 3)
AccentShade = static_cast<AccentColorShade>(6 - AccentShade); */
R = GetRValue(g_AccentPalette.Colors[(INT)AccentShade]);
G = GetGValue(g_AccentPalette.Colors[(INT)AccentShade]);
B = GetBValue(g_AccentPalette.Colors[(INT)AccentShade]);
return MyD2D1Color(A, R, G, B);
}
else
return MyD2D1Color(A, R, G, B);
}
D2D1_COLOR_F IsAccentColorPossibleD2D(BYTE R, BYTE G, BYTE B, AccentColorShade AccentShade = SystemAccentColorBase)
{
if (g_settings.AccentColorize)
{
// Change light/dark accent shades to dark/light depending theme dark mode
/* if (ShouldSystemUseDarkMode() && AccentShade > 3)
AccentShade = static_cast<AccentColorShade>(6 - AccentShade);
else if (!ShouldSystemUseDarkMode() && AccentShade < 3)
AccentShade = static_cast<AccentColorShade>(6 - AccentShade); */
R = GetRValue(g_AccentPalette.Colors[(INT)AccentShade]);
G = GetGValue(g_AccentPalette.Colors[(INT)AccentShade]);
B = GetBValue(g_AccentPalette.Colors[(INT)AccentShade]);
return MyD2D1Color(255, R, G, B);
}
else
return MyD2D1Color(R, G, B);
}
HRESULT WINAPI HookedDwmSetWindowAttribute(HWND hWnd, DWORD dwAttribute, LPCVOID pvAttribute, DWORD cbAttribute)
{
if(dwAttribute == DWMWA_BORDER_COLOR && IsWindowClass(hWnd, L"#32768") && g_settings.MenuBorderFlag && g_settings.BorderActiveColor != DWMWA_COLOR_NONE)
return DwmSetWindowAttribute_orig(hWnd, DWMWA_BORDER_COLOR, &g_settings.BorderActiveColor, sizeof(COLORREF));
if(!IsWindowEligible(hWnd))
return DwmSetWindowAttribute_orig(hWnd, dwAttribute, pvAttribute, cbAttribute);
if(!g_settings.TitlebarFlag)
{
if (dwAttribute == DWMWA_SYSTEMBACKDROP_TYPE || dwAttribute == DWMWA_USE_HOSTBACKDROPBRUSH)
{
if (g_settings.BgType == g_settings.AccentBlurBehind)
return DwmSetWindowAttribute_orig(hWnd, DWMWA_SYSTEMBACKDROP_TYPE, &AUTO, sizeof(UINT));
if(g_settings.BgType == g_settings.AcrylicSystemBackdrop)
return DwmSetWindowAttribute_orig(hWnd, DWMWA_SYSTEMBACKDROP_TYPE, &TRANSIENTWINDOW, sizeof(UINT));
else if(g_settings.BgType == g_settings.MicaAlt)
return DwmSetWindowAttribute_orig(hWnd, DWMWA_SYSTEMBACKDROP_TYPE, &TABBEDWINDOW, sizeof(UINT));
else if(g_settings.BgType == g_settings.Mica)
return DwmSetWindowAttribute_orig(hWnd, DWMWA_SYSTEMBACKDROP_TYPE, &MAINWINDOW, sizeof(UINT));
}
}
else if (dwAttribute == DWMWA_CAPTION_COLOR || (dwAttribute == DWMWA_SYSTEMBACKDROP_TYPE
&& (IsWindowClass(hWnd, L"CabinetWClass") || IsWindowClass(hWnd, L"TaskManagerWindow"))))
return DwmSetWindowAttribute_orig(hWnd, DWMWA_CAPTION_COLOR, &g_settings.g_TitlebarColor, sizeof(COLORREF));
// Effects on VS Studio, Windows Terminal ...
if(dwAttribute == DWMWA_BORDER_COLOR && g_settings.BorderFlag)
return DwmSetWindowAttribute_orig(hWnd, DWMWA_BORDER_COLOR, &g_settings.g_BorderColor, sizeof(COLORREF));
return DwmSetWindowAttribute_orig(hWnd, dwAttribute, pvAttribute, cbAttribute);
}
HRESULT WINAPI HookedDwmExtendFrameIntoClientArea(HWND hWnd, const MARGINS* pMarInset)
{
if(!IsWindowEligible(hWnd))
[[clang::musttail]]return DwmExtendFrameIntoClientArea_orig(hWnd, pMarInset);
if(g_settings.ExtendFrame)
{
if (!IsWindowClass(hWnd, L"CASCADIA_HOSTING_WINDOW_CLASS") )
{
static const MARGINS margins = {-1, -1, -1, -1};
[[clang::musttail]]return DwmExtendFrameIntoClientArea_orig(hWnd, &margins);
}
}
[[clang::musttail]]return DwmExtendFrameIntoClientArea_orig(hWnd, pMarInset);
}
HWND WINAPI HookedNtUserCreateWindowEx(DWORD dwExStyle,
PUNICODE_STRING UnsafeClassName,
LPCWSTR VersionedClass,
PUNICODE_STRING UnsafeWindowName,
DWORD dwStyle,
LONG x,
LONG y,
LONG nWidth,
LONG nHeight,
HWND hWndParent,
HMENU hMenu,
HINSTANCE hInstance,
LPVOID lpParam,
DWORD dwShowMode,
DWORD dwUnknown1,
DWORD dwUnknown2,
VOID* qwUnknown3)
{
HWND hWnd = NtUserCreateWindowEx_Original(
dwExStyle, UnsafeClassName, VersionedClass, UnsafeWindowName, dwStyle,
x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam,
dwShowMode, dwUnknown1, dwUnknown2, qwUnknown3);
if(hWnd)
NewWindowShown(hWnd);
return hWnd;
}
std::wstring GetThemeClass(HTHEME hTheme)
{
typedef HRESULT(WINAPI* pGetThemeClass)(HTHEME, LPCTSTR, INT);
static auto GetClassName = (pGetThemeClass)GetProcAddress(GetModuleHandleW(L"uxtheme"), MAKEINTRESOURCEA(74));
std::wstring ret;
if (GetClassName)
{
WCHAR buffer[255] = { 0 };
HRESULT hr = GetClassName(hTheme, buffer, 255);
return SUCCEEDED(hr) ? buffer : L"";
}
return ret;
}
// Fix Alpha of DrawTextW
// https://github.com/Maplespe/ExplorerBlurMica/blob/79c0ef4d017e32890e107ff98113507f831608b6/ExplorerBlurMica/HookDef.cpp#L859
INT WINAPI HookedDrawTextW(HDC hdc, LPCWSTR lpchText, INT cchText, LPRECT lprc, UINT format)
{
if (format & DT_CALCRECT || g_DrawTextWithGlowEntry)
return DrawTextW_orig(hdc, lpchText, cchText, lprc, format);
HRESULT hr = S_OK;
BLENDFUNCTION bf = { AC_SRC_OVER, 0, 255, AC_SRC_ALPHA };
BP_PAINTPARAMS bpParam;
bpParam.cbSize = sizeof(BP_PAINTPARAMS);
bpParam.dwFlags = BPPF_ERASE;
bpParam.prcExclude = nullptr;
bpParam.pBlendFunction = &bf;
HDC hDC = nullptr;
HPAINTBUFFER pbuffer = BeginBufferedPaint(hdc, lprc, BPBF_TOPDOWNDIB, &bpParam, &hDC);
if (pbuffer && hDC)
{
g_DrawTextWithGlowEntry = TRUE;
// Set the original DC information
SelectObject(hDC, GetCurrentObject(hdc, OBJ_FONT));
SetBkMode(hDC, GetBkMode(hdc));
SetBkColor(hDC, GetBkColor(hdc));
SetTextAlign(hDC, GetTextAlign(hdc));
SetTextCharacterExtra(hDC, GetTextCharacterExtra(hdc));
//SetTextColor(hDC, GetTextColor(hdc));
hr = DrawTextWithGlow(hDC, lpchText, cchText, lprc, format,
GetTextColor(hdc), 0, 0, 0, 0,
[](HDC hdc, LPWSTR lpchText, INT cchText, LPRECT lprc, UINT format, LPARAM lParam) WINAPI
{
return DrawTextW_orig(hdc, lpchText, cchText, lprc, format);
},
0);
EndBufferedPaint(pbuffer, TRUE);
g_DrawTextWithGlowEntry = FALSE;
return (SUCCEEDED(hr)) ? TRUE : DrawTextW_orig(hdc, lpchText, cchText, lprc, format);
}
return DrawTextW_orig(hdc, lpchText, cchText, lprc, format);
}
BOOL WINAPI HookedExtTextOutW(
HDC hdc,
INT x,
INT y,
UINT options,
const RECT* lprect,
LPCWSTR lpString,
UINT c,
const INT* lpDx)
{
if (!hdc || (!lpString && options != ETO_OPAQUE) || g_DrawTextWithGlowEntry)
return ExtTextOutW_orig(hdc, x, y, options, lprect, lpString, c, lpDx);
RECT textRect {0};
SIZE textSize = {0};
if (lprect) {
// Pass one line (borders) drawings
if (options == ETO_OPAQUE &&
((lprect->right-lprect->left) == 1 || (lprect->bottom-lprect->top) == 1))
textRect = *lprect;
else if (options != ETO_OPAQUE)
textRect = *lprect;
}
else if (options == ETO_GLYPH_INDEX)
{
if (GetTextExtentPointI(hdc, (WORD*)lpString, c, &textSize))
{
textRect.left = x;
textRect.top = y - textSize.cy;
textRect.right = x + textSize.cx ;
textRect.bottom = textSize.cy + y;
}
else
return ExtTextOutW_orig(hdc, x, y, options, lprect, lpString, c, lpDx);
}
else if (options == ETO_IGNORELANGUAGE)
{
if(!GetClipBox(hdc, &textRect)) // GetClipBox has a performance impact, not ideal
return ExtTextOutW_orig(hdc, x, y, options, lprect, lpString, c, lpDx);
}
else
{
if (GetTextExtentPoint32W(hdc, lpString, c, &textSize))
{
textRect.left = x;
textRect.top = y - textSize.cy;
textRect.right = x + textSize.cx;
textRect.bottom = textSize.cy + y;
}
else
return ExtTextOutW_orig(hdc, x, y, options, lprect, lpString, c, lpDx);
}
INT textRectWidth = textRect.right - textRect.left;
INT textRectHeight = textRect.bottom - textRect.top;
if (textRectWidth <= 0 || textRectHeight <= 0)
return ExtTextOutW_orig(hdc, x, y, options, lprect, lpString, c, lpDx);
COLORREF origTextColor = GetTextColor(hdc);
COLORREF origBkColor = GetBkColor(hdc);
COLORREF highlightSysClr = GetSysColor(COLOR_HIGHLIGHT);
BITMAPINFO bmi = {};
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmi.bmiHeader.biWidth = textRectWidth;
bmi.bmiHeader.biHeight = -textRectHeight;
bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biBitCount = 32;
bmi.bmiHeader.biCompression = BI_RGB;
VOID* pixels = nullptr;
HDC memDC = CreateCompatibleDC(hdc);
if (!memDC)
return ExtTextOutW_orig(hdc, x, y, options, lprect, lpString, c, lpDx);
HBITMAP dib = CreateDIBSection(memDC, &bmi, DIB_RGB_COLORS, &pixels, NULL, 0);
if (!dib) {
DeleteDC(memDC);
return ExtTextOutW_orig(hdc, x, y, options, lprect, lpString, c, lpDx);
}
HGDIOBJ oldBmp = SelectObject(memDC, dib);
HGDIOBJ oldFont = SelectObject(memDC, GetCurrentObject(hdc, OBJ_FONT));
SetTextAlign(memDC, GetTextAlign(hdc));
SetBkMode(memDC, TRANSPARENT);
RECT pRect;
if (lprect) {
pRect = {lprect->left - textRect.left, lprect->top - textRect.top,
lprect->right - textRect.left, lprect->bottom - textRect.top};
}
// The opaque text background applied to the background of text within editboxes
if (options & ETO_OPAQUE)
{
if (origBkColor == highlightSysClr) {
FillRect(hdc, lprect, (HBRUSH)GetStockObject(BLACK_BRUSH));
HBRUSH brush = CreateSolidBrush(origBkColor);
FillRect(memDC, &pRect, brush);
DeleteObject(brush);
}
else if (origBkColor != 0x00383838) // bypass editbox BkColor on open/save dialogs
{
FillRect(hdc, lprect, (HBRUSH)GetStockObject(BLACK_BRUSH));
HBRUSH brush = CreateSolidBrush(origBkColor);
FillRect(memDC, &pRect, brush);
DeleteObject(brush);
}
}
// White text mask
SetTextColor(memDC, RGB(255, 255, 255));
// Render text with removed the opaque background text flag, because it has already been done by us
WINBOOL res = ExtTextOutW_orig(memDC, x - textRect.left, y - textRect.top, options &~ ETO_OPAQUE, &pRect, lpString, c, lpDx);
BYTE txtR = GetRValue(origTextColor);
BYTE txtG = GetGValue(origTextColor);
BYTE txtB = GetBValue(origTextColor);
BYTE dstB = !(options & ETO_OPAQUE) ? 0 : GetBValue(origBkColor);
BYTE dstG = !(options & ETO_OPAQUE) ? 0 : GetGValue(origBkColor);
BYTE dstR = !(options & ETO_OPAQUE) ? 0 : GetRValue(origBkColor);
// Alpha Blend
BYTE alpha;
BYTE* p = (BYTE*)pixels;
for (INT i = 0; i < textRectWidth * textRectHeight; ++i) {
// Rec.709/sRGB luminance
alpha = (BYTE)((p[2] * 54 + p[1] * 183 + p[0] * 19) >> 8);
if (alpha)
{
p[0] = (BYTE)((txtB * alpha + dstB * (255 - alpha)) >> 8); // B
p[1] = (BYTE)((txtG * alpha + dstG * (255 - alpha)) >> 8); // G
p[2] = (BYTE)((txtR * alpha + dstR * (255 - alpha)) >> 8); // R
// full alpha highlight background fixes antialiased pixel bleed
p[3] = (options & ETO_OPAQUE && (origBkColor == highlightSysClr)) ? 255 : alpha; // A
}
p += 4;
}
// Blend composited text
BLENDFUNCTION blend = {AC_SRC_OVER, 0, 255, AC_SRC_ALPHA};
AlphaBlend(hdc, textRect.left, textRect.top, textRectWidth, textRectHeight,
memDC, 0, 0, textRectWidth, textRectHeight, blend);
SelectObject(memDC, oldFont);
SelectObject(memDC, oldBmp);
DeleteObject(dib);
DeleteDC(memDC);
return res;
}
// Prevent recursive calls within the DrawText class API and perform Alpha repair
// https://github.com/Maplespe/ExplorerBlurMica/blob/79c0ef4d017e32890e107ff98113507f831608b6/ExplorerBlurMica/HookDef.cpp#L1085
HRESULT WINAPI HookedDrawThemeTextEx(HTHEME hTheme, HDC hdc, INT iPartId, INT iStateId, LPCWSTR pszText,
INT cchText, DWORD dwTextFlags, LPRECT pRect, const DTTOPTS* pOptions)
{
std::wstring ThemeClassName = GetThemeClass(hTheme);
if (pOptions && !(pOptions->dwFlags & DTT_CALCRECT) && !((pOptions->dwFlags & DTT_COMPOSITED) && ThemeClassName != L"Menu"))
{
HRESULT hr;
BLENDFUNCTION bf = { AC_SRC_OVER, 0, 255, AC_SRC_ALPHA };
BP_PAINTPARAMS bpParam;
bpParam.cbSize = sizeof(BP_PAINTPARAMS);
bpParam.dwFlags = BPPF_ERASE;
bpParam.prcExclude = nullptr;
bpParam.pBlendFunction = &bf;
HDC hDC = nullptr;
HPAINTBUFFER pbuffer = BeginBufferedPaint(hdc, pRect, BPBF_TOPDOWNDIB, &bpParam, &hDC);
if (pbuffer && hDC)
{
g_DrawTextWithGlowEntry = TRUE;
// Set the original DC information
SelectObject(hDC, GetCurrentObject(hdc, OBJ_FONT));
SetBkMode(hDC, GetBkMode(hdc));
SetBkColor(hDC, GetBkColor(hdc));
SetTextAlign(hDC, GetTextAlign(hdc));
SetTextCharacterExtra(hDC, GetTextCharacterExtra(hdc));
//SetTextColor(hDC, GetTextColor(hdc));