1
1
#include " pch.h"
2
2
#include " tflapi.h"
3
+ #include " SettingsHelper.h"
3
4
#include " DebugHelper.h"
4
5
#include " ThemeHelper.h"
5
6
#include " AcrylicHelper.h"
@@ -26,6 +27,10 @@ DetoursHook DeleteDCHook("Gdi32", "DeleteDC", MyDeleteDC);
26
27
DetoursHook DeleteObjectHook (" Gdi32" , " DeleteObject" , MyDeleteObject);
27
28
28
29
thread_local HWND g_hWnd = nullptr ;
30
+ #pragma data_seg("shared")
31
+ Settings g_settings = {};
32
+ #pragma data_seg()
33
+ #pragma comment(linker,"/SECTION:shared,RWS")
29
34
30
35
void SetCurrentMenuFlyout (HWND hWnd)
31
36
{
@@ -157,7 +162,7 @@ HRESULT WINAPI TranslucentFlyoutsLib::MyDrawThemeBackground(
157
162
if (
158
163
IsAllowTransparent () and
159
164
VerifyThemeData (hTheme, TEXT (" Tooltip" )) and
160
- (GetCurrentFlyoutPolicy () & Tooltip) and
165
+ (g_settings. GetPolicy () & Tooltip) and
161
166
(
162
167
iPartId == TTP_STANDARD or
163
168
iPartId == TTP_BALLOON or
@@ -170,7 +175,7 @@ HRESULT WINAPI TranslucentFlyoutsLib::MyDrawThemeBackground(
170
175
!VerifyThemeBackgroundTransparency (hTheme, iPartId, iStateId)
171
176
)
172
177
{
173
- if (!DoBufferedPaint (hdc, &Rect , f, (BYTE)GetCurrentFlyoutOpacity ()))
178
+ if (!DoBufferedPaint (hdc, &Rect , f, (BYTE)g_settings. GetOpacity ()))
174
179
{
175
180
goto Default;
176
181
}
@@ -187,15 +192,15 @@ HRESULT WINAPI TranslucentFlyoutsLib::MyDrawThemeBackground(
187
192
VerifyThemeData (hTheme, TEXT (" Toolbar" )) and
188
193
(iPartId == 0 and iStateId == 0 ) and
189
194
(
190
- (GetCurrentFlyoutPolicy () & ViewControl) and
195
+ (g_settings. GetPolicy () & ViewControl) and
191
196
(
192
197
IsViewControlFlyout (GetParent (GetWindowFromHDC (hdc))) or
193
198
!IsWindow (GetWindowFromHDC (hdc))
194
199
)
195
200
)
196
201
)
197
202
{
198
- if (!DoBufferedPaint (hdc, &Rect , f, (BYTE)GetCurrentFlyoutOpacity ()))
203
+ if (!DoBufferedPaint (hdc, &Rect , f, (BYTE)g_settings. GetOpacity ()))
199
204
{
200
205
goto Default;
201
206
}
@@ -207,12 +212,12 @@ HRESULT WINAPI TranslucentFlyoutsLib::MyDrawThemeBackground(
207
212
(
208
213
VerifyThemeData (hTheme, TEXT (" Menu" )) and
209
214
(
210
- (GetCurrentFlyoutPolicy () & PopupMenu) and
215
+ (g_settings. GetPolicy () & PopupMenu) and
211
216
!IsViewControlFlyout (GetWindowFromHDC (hdc)) and
212
217
!IsViewControlFlyout (GetParent (GetWindowFromHDC (hdc)))
213
218
) or
214
219
(
215
- (GetCurrentFlyoutPolicy () & ViewControl) and
220
+ (g_settings. GetPolicy () & ViewControl) and
216
221
(
217
222
IsViewControlFlyout (GetWindowFromHDC (hdc)) or
218
223
IsViewControlFlyout (GetParent (GetWindowFromHDC (hdc)))
@@ -227,8 +232,8 @@ HRESULT WINAPI TranslucentFlyoutsLib::MyDrawThemeBackground(
227
232
{
228
233
SetWindowEffect (
229
234
GetCurrentMenuFlyout (),
230
- GetCurrentFlyoutEffect (),
231
- GetCurrentFlyoutBorder ()
235
+ g_settings. GetEffect (),
236
+ g_settings. GetBorder ()
232
237
);
233
238
SetCurrentMenuFlyout (nullptr );
234
239
}
@@ -238,7 +243,7 @@ HRESULT WINAPI TranslucentFlyoutsLib::MyDrawThemeBackground(
238
243
iPartId == MENU_POPUPBACKGROUND or
239
244
iPartId == MENU_POPUPGUTTER or
240
245
(
241
- GetCurrentFlyoutColorizeOption () == 0 ?
246
+ g_settings. GetColorizeOption () == 0 ?
242
247
(iPartId == MENU_POPUPITEM and iStateId != MPI_HOT) :
243
248
(iPartId == MENU_POPUPITEM)
244
249
) or
@@ -253,7 +258,7 @@ HRESULT WINAPI TranslucentFlyoutsLib::MyDrawThemeBackground(
253
258
)
254
259
)
255
260
{
256
- if (!DoBufferedPaint (hdc, &Rect , f, (BYTE)GetCurrentFlyoutOpacity (), BPPF_ERASE | (iPartId == MENU_POPUPBORDERS ? BPPF_NONCLIENT : 0UL )))
261
+ if (!DoBufferedPaint (hdc, &Rect , f, (BYTE)g_settings. GetOpacity (), BPPF_ERASE | (iPartId == MENU_POPUPBORDERS ? BPPF_NONCLIENT : 0UL )))
257
262
{
258
263
goto Default;
259
264
}
@@ -322,9 +327,9 @@ HRESULT WINAPI TranslucentFlyoutsLib::MyDrawThemeTextEx(
322
327
if (
323
328
IsAllowTransparent () and
324
329
(
325
- (VerifyThemeData (hTheme, TEXT (" Menu" )) and GetCurrentFlyoutPolicy () & PopupMenu) or
326
- (VerifyThemeData (hTheme, TEXT (" Toolbar" )) and GetCurrentFlyoutPolicy () & ViewControl) or
327
- (VerifyThemeData (hTheme, TEXT (" Tooltip" )) and GetCurrentFlyoutPolicy () & Tooltip)
330
+ (VerifyThemeData (hTheme, TEXT (" Menu" )) and g_settings. GetPolicy () & PopupMenu) or
331
+ (VerifyThemeData (hTheme, TEXT (" Toolbar" )) and g_settings. GetPolicy () & ViewControl) or
332
+ (VerifyThemeData (hTheme, TEXT (" Tooltip" )) and g_settings. GetPolicy () & Tooltip)
328
333
) and
329
334
pOptions and
330
335
(
@@ -404,9 +409,9 @@ HRESULT WINAPI TranslucentFlyoutsLib::MyDrawThemeText(
404
409
IsAllowTransparent () and
405
410
pRect and
406
411
(
407
- (VerifyThemeData (hTheme, TEXT (" Menu" )) and GetCurrentFlyoutPolicy () & PopupMenu) or
408
- (VerifyThemeData (hTheme, TEXT (" Toolbar" )) and GetCurrentFlyoutPolicy () & ViewControl) or
409
- (VerifyThemeData (hTheme, TEXT (" Tooltip" )) and GetCurrentFlyoutPolicy () & Tooltip)
412
+ (VerifyThemeData (hTheme, TEXT (" Menu" )) and g_settings. GetPolicy () & PopupMenu) or
413
+ (VerifyThemeData (hTheme, TEXT (" Toolbar" )) and g_settings. GetPolicy () & ViewControl) or
414
+ (VerifyThemeData (hTheme, TEXT (" Tooltip" )) and g_settings. GetPolicy () & Tooltip)
410
415
)
411
416
)
412
417
{
@@ -621,7 +626,7 @@ BOOL WINAPI TranslucentFlyoutsLib::MySetMenuInfo(
621
626
(lpMenuInfo->fMask & MIM_BACKGROUND) and
622
627
lpMenuInfo->hbrBack and
623
628
IsAllowTransparent () and
624
- (GetCurrentFlyoutPolicy () & PopupMenu)
629
+ (g_settings. GetPolicy () & PopupMenu)
625
630
)
626
631
{
627
632
PBYTE pvBits = nullptr ;
@@ -639,7 +644,7 @@ BOOL WINAPI TranslucentFlyoutsLib::MySetMenuInfo(
639
644
GetBValue (dwColor),
640
645
GetGValue (dwColor),
641
646
GetRValue (dwColor),
642
- (BYTE)GetCurrentFlyoutOpacity ()
647
+ (BYTE)g_settings. GetOpacity ()
643
648
);
644
649
// 创建位图画刷
645
650
// 只有位图画刷才有Alpha值
@@ -696,7 +701,7 @@ BOOL WINAPI TranslucentFlyoutsLib::MySetMenuItemBitmaps(
696
701
{
697
702
BOOL bResult = FALSE ;
698
703
699
- if (IsAllowTransparent () and GetCurrentFlyoutPolicy () & PopupMenu)
704
+ if (IsAllowTransparent () and g_settings. GetPolicy () & PopupMenu)
700
705
{
701
706
PrepareAlpha (hBitmapUnchecked);
702
707
PrepareAlpha (hBitmapChecked);
@@ -721,7 +726,7 @@ BOOL WINAPI TranslucentFlyoutsLib::MyInsertMenuItemW(
721
726
{
722
727
BOOL bResult = FALSE ;
723
728
724
- if (IsAllowTransparent () and lpmii and (lpmii->fMask & MIIM_CHECKMARKS or lpmii->fMask & MIIM_BITMAP) and GetCurrentFlyoutPolicy () & PopupMenu)
729
+ if (IsAllowTransparent () and lpmii and (lpmii->fMask & MIIM_CHECKMARKS or lpmii->fMask & MIIM_BITMAP) and g_settings. GetPolicy () & PopupMenu)
725
730
{
726
731
PrepareAlpha (lpmii->hbmpItem );
727
732
PrepareAlpha (lpmii->hbmpUnchecked );
@@ -745,7 +750,7 @@ BOOL WINAPI TranslucentFlyoutsLib::MySetMenuItemInfoW(
745
750
{
746
751
BOOL bResult = FALSE ;
747
752
748
- if (IsAllowTransparent () and lpmii and (lpmii->fMask & MIIM_CHECKMARKS or lpmii->fMask & MIIM_BITMAP) and GetCurrentFlyoutPolicy () & PopupMenu)
753
+ if (IsAllowTransparent () and lpmii and (lpmii->fMask & MIIM_CHECKMARKS or lpmii->fMask & MIIM_BITMAP) and g_settings. GetPolicy () & PopupMenu)
749
754
{
750
755
PrepareAlpha (lpmii->hbmpItem );
751
756
PrepareAlpha (lpmii->hbmpUnchecked );
@@ -844,16 +849,16 @@ void TranslucentFlyoutsLib::OnWindowsCreated(HWND hWnd)
844
849
{
845
850
if (IsAllowTransparent ())
846
851
{
847
- if (IsPopupMenuFlyout (hWnd) and GetCurrentFlyoutPolicy () & PopupMenu)
852
+ if (IsPopupMenuFlyout (hWnd) and g_settings. GetPolicy () & PopupMenu)
848
853
{
849
854
SetCurrentMenuFlyout (hWnd);
850
855
}
851
- if (IsViewControlFlyout (hWnd) and GetCurrentFlyoutPolicy () & ViewControl)
856
+ if (IsViewControlFlyout (hWnd) and g_settings. GetPolicy () & ViewControl)
852
857
{
853
858
SetWindowEffect (
854
859
hWnd,
855
- GetCurrentFlyoutEffect (),
856
- GetCurrentFlyoutBorder ()
860
+ g_settings. GetEffect (),
861
+ g_settings. GetBorder ()
857
862
);
858
863
}
859
864
}
@@ -868,12 +873,12 @@ void TranslucentFlyoutsLib::OnWindowShowed(HWND hWnd)
868
873
{
869
874
if (IsAllowTransparent ())
870
875
{
871
- if (IsTooltipFlyout (hWnd) and GetCurrentFlyoutPolicy () & Tooltip)
876
+ if (IsTooltipFlyout (hWnd) and g_settings. GetPolicy () & Tooltip)
872
877
{
873
878
SetWindowEffect (
874
879
hWnd,
875
- GetCurrentFlyoutEffect (),
876
- GetCurrentFlyoutBorder ()
880
+ g_settings. GetEffect (),
881
+ g_settings. GetBorder ()
877
882
);
878
883
}
879
884
}
0 commit comments