@@ -12,11 +12,50 @@ interface
12
12
13
13
const
14
14
WCA_ACCENT_POLICY = 19 ;
15
+ ACCENT_DISABLED = 0 ;
15
16
ACCENT_ENABLE_GRADIENT = 1 ;
16
17
ACCENT_ENABLE_TRANSPARENTGRADIENT = 2 ;
17
18
ACCENT_ENABLE_BLURBEHIND = 3 ;
19
+ ACCENT_ENABLE_ACRYLICBLURBEHIND = 4 ;
18
20
21
+ // https://stackoverflow.com/a/22105803/537347 Windows 8 or newer only
22
+ IID_AppVisibility: TGUID = ' {2246EA2D-CAEA-4444-A3C4-6DE827E44313}' ;
23
+ CLSID_AppVisibility: TGUID = ' {7E5FE3D9-985F-4908-91F9-EE19F9FD1514}' ;
24
+ // IID_IAppVisibilityEvents: TGUID = '{6584CE6B-7D82-49C2-89C9-C6BC02BA8C38}';
19
25
type
26
+
27
+ MONITOR_APP_VISIBILITY = (
28
+ MAV_UNKNOWN = 0 ,
29
+ MAV_NO_APP_VISIBLE = 1 ,
30
+ MAV_APP_VISIBLE = 2
31
+ );
32
+ // *********************************************************************//
33
+ // Interface: IAppVisibilityEvents
34
+ // Flags: (0)
35
+ // GUID: {6584CE6B-7D82-49C2-89C9-C6BC02BA8C38}
36
+ // *********************************************************************//
37
+ IAppVisibilityEvents = interface (IUnknown)
38
+ [' {6584CE6B-7D82-49C2-89C9-C6BC02BA8C38}' ]
39
+ function AppVisibilityOnMonitorChanged (hMonitor: HMONITOR;
40
+ previousMode: MONITOR_APP_VISIBILITY;
41
+ currentMode: MONITOR_APP_VISIBILITY):HRESULT; stdcall;
42
+ function LauncherVisibilityChange (currentVisibleState: BOOL): HRESULT; stdcall;
43
+ end ;
44
+
45
+
46
+ // *********************************************************************//
47
+ // Interface: IAppVisibility
48
+ // Flags: (0)
49
+ // GUID: {2246EA2D-CAEA-4444-A3C4-6DE827E44313}
50
+ // *********************************************************************//
51
+ IAppVisibility = interface (IUnknown)
52
+ [' {2246EA2D-CAEA-4444-A3C4-6DE827E44313}' ]
53
+ function GetAppVisibilityOnMonitor (monitor: HMONITOR; out pMode: MONITOR_APP_VISIBILITY): HRESULT; stdcall;
54
+ function IsLauncherVisible (out pfVisible: BOOL): HRESULT; stdcall;
55
+ function Advise (pCallBack: IAppVisibilityEvents; out pdwCookie: DWORD): HRESULT; stdcall;
56
+ function Unadvise (dwCookie: DWORD): HRESULT; stdcall;
57
+ end ;
58
+
20
59
AccentPolicy = packed record
21
60
AccentState: Integer;
22
61
AccentFlags: Integer;
@@ -44,6 +83,7 @@ TTaskComponent = record
44
83
Rect: TRect;
45
84
end ;
46
85
86
+ PTaskbar = ^TTaskbar;
47
87
TTaskbar = class
48
88
private
49
89
_reg: TRegistry;
@@ -72,7 +112,9 @@ TTaskbar = class
72
112
function _IsTransparent : Boolean;
73
113
procedure HideStartBtn ;
74
114
procedure ShowStartBtn ;
115
+ function _getIconsRect : TRect;
75
116
public
117
+ property Handle: THandle read _handle;
76
118
property Position: TTaskPosition read _position write _position;
77
119
property MonitoID: Integer read _monitorId;
78
120
property MonitorRect: TRect read _monitorRect;
@@ -82,7 +124,8 @@ TTaskbar = class
82
124
83
125
property AppsLeft: Integer read _appsBtnLeft;
84
126
property AppsRight: Integer read _appsBtnRight;
85
- property MSTaskList: TRect read _MSTaskListWClass.Rect;
127
+ property MSTaskListRect: TRect read _getIconsRect;
128
+ property MSTaskRect: TRect read _MSTaskSwWClass.Rect;
86
129
property TrayRect: TRect read _trayNotifyWnd.Rect;
87
130
property StartRect: TRect read _start.Rect;
88
131
@@ -98,6 +141,18 @@ TTaskbar = class
98
141
procedure FullTaskBar ;
99
142
procedure UpdateTaskbarHandle ;
100
143
function GetMonitor : TMonitor;
144
+ function IsStartMenuVisible : Boolean;
145
+ end ;
146
+
147
+ TTaskbars = class (TList)
148
+ private
149
+ function Get (Index: Integer): PTaskbar;
150
+ public
151
+ function Add (Value : TTaskbar): Integer;
152
+ procedure Refresh ;
153
+ procedure CenterAppsButtons (center: Boolean = True; relative: Boolean = False);
154
+ procedure Notify (Ptr: Pointer; Action: TListNotification); override;
155
+ property Items[Index: Integer]: PTaskbar read Get; default;
101
156
end ;
102
157
103
158
function SetWindowCompositionAttribute (hWnd: HWND; var data: WindowCompositionAttributeData): Integer; stdcall;
@@ -112,6 +167,8 @@ implementation
112
167
113
168
{ TTaskbar }
114
169
170
+ uses ActiveX, Shlobj, ComObj;
171
+
115
172
procedure TTaskbar.CenterAppsButtons (center: Boolean = True; relative: Boolean = False);
116
173
var
117
174
aLeft, aTop: Integer;
@@ -211,7 +268,7 @@ procedure TTaskbar.FullTaskBar;
211
268
212
269
if _appsBtnLeft = 0 then Exit;
213
270
214
- SetWindowPos(_MSTaskSwWClass.Handle, 0 , 0 , 0 , _rect.Width, _MSTaskSwWClass.Rect.Height, SWP_NOACTIVATE );
271
+ SetWindowPos(_MSTaskSwWClass.Handle, 0 , 0 , 0 , _rect.Width, _MSTaskSwWClass.Rect.Height, SWP_NOSENDCHANGING );
215
272
end ;
216
273
217
274
function TTaskbar.GetMonitor : TMonitor;
@@ -240,6 +297,7 @@ procedure TTaskbar.HideStartBtn;
240
297
Hide(_start.Handle);
241
298
end ;
242
299
300
+
243
301
procedure TTaskbar.NotifyAreaVisible (visible: Boolean);
244
302
begin
245
303
if visible then
@@ -277,12 +335,14 @@ procedure TTaskbar.Transparent;
277
335
if _notaskbar then Exit;
278
336
279
337
accent.AccentState := _transstyle;
280
- // accent.GradientColor := $00000000;
338
+ accent.GradientColor := $00000000 ;
339
+ accent.AccentFlags := 2 ; // 2: seems to hide the border
281
340
data.Attribute := WCA_ACCENT_POLICY;
282
341
data.SizeOfData := SizeOf(accent);
283
342
data.Data := @accent;
284
343
285
- SetWindowCompositionAttribute(_handle, data);
344
+ if _transstyle = ACCENT_ENABLE_TRANSPARENTGRADIENT then
345
+ SetWindowCompositionAttribute(_handle, data);
286
346
end ;
287
347
288
348
procedure TTaskbar.UpdateTaskbarHandle ;
@@ -493,6 +553,37 @@ procedure TTaskbar.UpdateTaskbarInfo;
493
553
end ;
494
554
end ;
495
555
556
+ function TTaskbar.IsStartMenuVisible : Boolean;
557
+ var
558
+ acc: IAppVisibility;
559
+ res: HRESULT;
560
+ isLauncherVisible: BOOL;
561
+ begin
562
+ Result := False;
563
+ // Initialization of COM is required to use the AppVisibility (CLSID_AppVisibility) object
564
+ res := CoInitializeEx(nil , COINIT_APARTMENTTHREADED);
565
+ if Succeeded(res) then
566
+ begin
567
+ // Create the App Visibility component
568
+ res := CoCreateInstance(CLSID_AppVisibility, nil , CLSCTX_ALL, IID_AppVisibility, acc);
569
+ if Succeeded(res) then
570
+ begin
571
+ res := acc.IsLauncherVisible(isLauncherVisible);
572
+ if Succeeded(res) then
573
+ Result := Boolean(isLauncherVisible);
574
+ end ;
575
+
576
+ end ;
577
+
578
+ end ;
579
+
580
+ function TTaskbar._getIconsRect : TRect;
581
+ begin
582
+ Result := _MSTaskListWClass.Rect;
583
+
584
+ Result.Right := _appsBtnRight;
585
+ end ;
586
+
496
587
function TTaskbar._IsTransparent : Boolean;
497
588
begin
498
589
_translucent := False;
@@ -511,4 +602,67 @@ function TTaskbar._IsTransparent: Boolean;
511
602
Result := _translucent;
512
603
end ;
513
604
605
+ { TTaskbars }
606
+
607
+ function TTaskbars.Add (Value : TTaskbar): Integer;
608
+ begin
609
+ Result := inherited Add(Value );
610
+ end ;
611
+
612
+ procedure TTaskbars.CenterAppsButtons (center, relative: Boolean);
613
+ var
614
+ I: Integer;
615
+ begin
616
+ for I := 0 to Count - 1 do
617
+ Items[I].CenterAppsButtons(center, relative);
618
+ end ;
619
+
620
+ function TTaskbars.Get (Index: Integer): PTaskbar;
621
+ begin
622
+ Result := PTaskbar(inherited Get(Index));
623
+ end ;
624
+
625
+ procedure TTaskbars.Notify (Ptr: Pointer; Action: TListNotification);
626
+ begin
627
+ inherited ;
628
+
629
+ if Action = lnDeleted then
630
+ FreeMem(Ptr);
631
+ end ;
632
+
633
+ procedure TTaskbars.Refresh ;
634
+ var
635
+ LHDesktop: HWND;
636
+ LHWindow: HWND;
637
+ LHParent: HWND;
638
+ LExStyle: DWORD;
639
+ I: integer;
640
+ AppClassName: array [0 ..255 ] of char;
641
+ Cloaked: Cardinal;
642
+ Taskbar: TTaskbar;
643
+ begin
644
+ LHDesktop:=GetDesktopWindow;
645
+ LHWindow:=GetWindow(LHDesktop,GW_CHILD);
646
+
647
+ while LHWindow <> 0 do
648
+ begin
649
+ GetClassName(LHWindow, AppClassName, 255 );
650
+ LHParent:=GetWindowLong(LHWindow,GWL_HWNDPARENT);
651
+ LExStyle:=GetWindowLong(LHWindow,GWL_EXSTYLE);
652
+
653
+ if IsWindowVisible(LHWindow)
654
+ and (AppClassName = ' Shell_TrayWnd' )
655
+ or (AppClassName = ' Shell_SecondaryTrayWnd' )
656
+ and ((LHParent=0 )or (LHParent=LHDesktop))
657
+ and (Screen.MonitorFromWindow(LHWindow).MonitorNum <> 0 )
658
+ then
659
+ begin
660
+ Taskbar := TTaskbar.Create();
661
+ Add(Taskbar);
662
+ end ;
663
+ LHWindow:=GetWindow(LHWindow, GW_HWNDNEXT);
664
+ end ;
665
+
666
+ end ;
667
+
514
668
end .
0 commit comments