Skip to content

Commit

Permalink
Added workaround to restore taskbar opacity on secondary taskbars and…
Browse files Browse the repository at this point in the history
… fixed transparent taskbar border on drawing
  • Loading branch information
vhanla committed Sep 24, 2019
1 parent 8dd94bf commit 257bf3d
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 32 deletions.
31 changes: 9 additions & 22 deletions main.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,6 @@ object Form1: TForm1
Caption = 'tbsAbout'
ImageIndex = 1
TabVisible = False
ExplicitLeft = 0
ExplicitTop = 0
ExplicitWidth = 0
ExplicitHeight = 0
object headingAbout: TUText
AlignWithMargins = True
Left = 0
Expand Down Expand Up @@ -422,15 +418,11 @@ object Form1: TForm1
Caption = 'tbsDocks'
ImageIndex = 2
TabVisible = False
ExplicitLeft = 0
ExplicitTop = 0
ExplicitWidth = 0
ExplicitHeight = 0
object UText2: TUText
AlignWithMargins = True
Left = 0
Top = 20
Width = 53
Width = 698
Height = 28
Margins.Left = 0
Margins.Top = 20
Expand All @@ -445,6 +437,7 @@ object Form1: TForm1
Font.Style = []
ParentFont = False
TextKind = tkHeading
ExplicitWidth = 53
end
end
object tbsPinnedIcons: TTabSheet
Expand All @@ -463,26 +456,20 @@ object Form1: TForm1
inherited UText3: TUText
Width = 698
end
inherited UButton5: TUButton
Anchors = [akTop]
OnClick = frameIcons1UButton5Click
end
inherited UButton2: TUButton
OnClick = frameIcons1UButton2Click
end
inherited UButton3: TUButton
Anchors = [akLeft, akTop, akBottom]
inherited Panel1: TPanel
inherited UButton1: TUButton
Anchors = [akLeft, akTop, akRight]
end
inherited UButton2: TUButton
Anchors = [akLeft, akTop, akRight]
end
end
end
end
object tbsMore: TTabSheet
Caption = 'tbsMore'
ImageIndex = 4
TabVisible = False
ExplicitLeft = 0
ExplicitTop = 0
ExplicitWidth = 0
ExplicitHeight = 0
end
object tbsSkins: TTabSheet
Caption = 'tbsSkins'
Expand Down
19 changes: 14 additions & 5 deletions main.pas
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ TForm1 = class(TUForm)

public
{ Public declarations }
AppPath, AppFolder, AppExe: String;
Taskbars: TTaskbars;
function ForceForeground(hwnd: HWND): Boolean;
procedure CheckUpdate;
Expand Down Expand Up @@ -380,6 +381,10 @@ function ShellProc(nCode: Integer; wParam: WPARAM; lParam: LPARAM): LRESULT; std

procedure TForm1.FormCreate(Sender: TObject);
begin
AppPath := ParamStr(0);
AppFolder := ExtractFilePath(AppPath);
AppExe := ExtractFileName(AppPath);

Self.ThemeManager := ThemeManager;
AutoStartState;
//CreateDB;
Expand Down Expand Up @@ -445,7 +450,7 @@ procedure TForm1.mnuFullClick(Sender: TObject);
// mnuFull.Checked := not mnuFull.Checked;
//GetModuleFileName(GetWindowThreadProcessId(FindWindow('Shell_TrayWnd', nil)),ex,2048);

InjectDLL(GetProcessIdByName('explorer.exe'),PChar(ExtractFilePath(ParamStr(0))+'TaskbarDll.dll'));
InjectDLL(GetProcessIdByName('explorer.exe'),PChar(AppFolder+'TaskbarDll.dll'));
end;

function TForm1.GetProcessIdByName(s: String): DWORD;
Expand Down Expand Up @@ -574,7 +579,7 @@ procedure TForm1.LoadINI;
ini: TIniFile;
val: Boolean;
begin
ini := TIniFile.Create(ExtractFilePath(ParamStr(0))+'settings.ini');
ini := TIniFile.Create(AppFolder+'settings.ini');
try
mnuStart.Checked := ini.ReadBool('TaskbarDock','ShowStartButton', True);
mnuTray.Checked := ini.ReadBool('TaskbarDock','ShowTrayArea', True);
Expand All @@ -598,7 +603,7 @@ procedure TForm1.SaveINI;
var
ini: TIniFile;
begin
ini := TIniFile.Create(ExtractFilePath(ParamStr(0))+'settings.ini');
ini := TIniFile.Create(AppFolder+'settings.ini');
try
ini.WriteBool('TaskbarDock','ShowStartButton', mnuStart.Checked);
ini.WriteBool('TaskbarDock','ShowTrayArea', mnuTray.Checked);
Expand Down Expand Up @@ -637,7 +642,8 @@ procedure TForm1.mnuTransparentClick(Sender: TObject);
end;
Sleep(1);
end;

// this restores secondary taskbars too
SendNotifyMessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0, LongInt(PChar('TraySettings')));
end;

SyncSettingsPage;
Expand Down Expand Up @@ -684,7 +690,7 @@ procedure TForm1.SetAutoStart(runwithwindows: Boolean);
reg.RootKey := HKEY_CURRENT_USER;
reg.OpenKey('SOFTWARE\Microsoft\Windows\CurrentVersion\Run', False);
if runwithwindows then
reg.WriteString('TaskbarDock', ParamStr(0))
reg.WriteString('TaskbarDock', AppPath)
else
if reg.ValueExists('TaskbarDock') then
reg.DeleteValue('TaskbarDock');
Expand Down Expand Up @@ -1000,6 +1006,9 @@ procedure TForm1.Button1Click(Sender: TObject);
PNGBitmap: TGPBitmap;
BitmapHandle: HBITMAP;
begin
Taskbars.PinTaskbar(PChar(AppPath), false);

Exit;
// ListBox1.Items := Taskbars.ListMainTaskbarElements;

SetWindowLong( Taskbars.MainTaskbar.MSTaskListWClass.Handle,GWL_EXSTYLE ,
Expand Down
16 changes: 11 additions & 5 deletions taskbar.pas
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ TTaskbars = class(TList)
property Autohide: Boolean read GetAutoHideInfo write SetAutoHide;
property SmallIcons: Boolean read GetSmallIcons write SetSmallIcons;
procedure UpdateTaskbarInfo;
procedure Transparent;
procedure Transparent(Value: Boolean = True);
procedure BeginUpdate;
procedure EndUpdate;

Expand Down Expand Up @@ -508,7 +508,7 @@ procedure TTaskbars.NotifyAreaVisible(visible: Boolean);
end;

procedure TTaskbars.PinTaskbar(lnkFile: PChar; pin: Boolean = True;
defaultSize: DWORD);
defaultSize: DWORD = 0);
var
pPEB: Pointer;
dwOrigLen, dwLen: DWORD;
Expand Down Expand Up @@ -727,7 +727,7 @@ procedure TTaskbars.StartBtnVisible(Index:Integer; Visible: Boolean);
ShowWindow(Items[Index]._start.Handle, SW_HIDE);
end;

procedure TTaskbars.Transparent;
procedure TTaskbars.Transparent(Value: Boolean = True);
var
I: Integer;
accent: AccentPolicy;
Expand All @@ -739,9 +739,15 @@ procedure TTaskbars.Transparent;
begin
//if _notaskbar then Exit;
//Items[I]._transstyle := ACCENT_ENABLE_TRANSPARENTGRADIENT;
accent.AccentState := ACCENT_ENABLE_TRANSPARENTGRADIENT; //Items[I]._transstyle;
if Value then
accent.AccentState := ACCENT_ENABLE_TRANSPARENTGRADIENT //Items[I]._transstyle;
else
accent.AccentState := ACCENT_ENABLE_GRADIENT;
accent.GradientColor := $00000000;
accent.AccentFlags := 2; // 2: seems to hide the border
if Value then
accent.AccentFlags := not $20 and not $40 and not $80 and not $100
else // draw left, top, right and bottom borders
accent.AccentFlags := $20 or $40 or $80 or $100;
data.Attribute := WCA_ACCENT_POLICY;
data.SizeOfData := SizeOf(accent);
data.Data := @accent;
Expand Down

0 comments on commit 257bf3d

Please sign in to comment.