Skip to content

Commit 284e1d3

Browse files
committed
Added
1 parent 6708085 commit 284e1d3

File tree

5 files changed

+160
-24
lines changed

5 files changed

+160
-24
lines changed

BetterTaskbar.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@
166166
</ItemGroup>
167167
<ItemGroup>
168168
<Image Include="Resources\icon.ico" />
169+
<Image Include="Resources\taskbar.gif" />
169170
</ItemGroup>
170171
<ItemGroup>
171172
<ResourceCompile Include="Resources\Resource.rc" />

Headers/AutoCast.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@ class AutoCast
55
{
66
public:
77
explicit AutoCast(T any) noexcept : _any(any) {}
8-
template <typename T> T ToAuto() noexcept { return T(_any); }
8+
template <typename T> T ToAuto() noexcept { return (T)_any; }
9+
template <typename T> T ToStatic() noexcept { return static_cast<T>(_any); }
10+
template <typename T> T ToConst() noexcept { return const_cast<T>(_any); }
11+
template <typename T> T ToReinterpret() noexcept { return reinterpret_cast<T>(_any); }
912
template <typename T> operator T*() const noexcept { return (T*)_any; }
13+
template <typename T> operator T() const noexcept { return (T)_any; }
1014

1115
private:
1216
T _any;

Headers/Taskbar.h

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,8 @@ void SetWindowBlur(HWND hWnd, AccentState AccentState, int Flags = 2, int color
3939
}
4040
}
4141

42-
void CenterTaskBar(int offset, bool def = false)
42+
int CenterTaskBar(int offset, bool def = false, bool justret = false)
4343
{
44-
//const int result = SetProcessDpiAwareness(PROCESS_PER_MONITOR_DPI_AWARE);
45-
4644
HWND taskbar = FindWindowA("Shell_TrayWnd", NULL);
4745
HWND panel = FindWindowExA(taskbar, NULL, "ReBarWindow32", NULL);
4846
HWND panel2 = FindWindowExA(panel, NULL, "MSTaskSwWClass", NULL);
@@ -86,13 +84,17 @@ void CenterTaskBar(int offset, bool def = false)
8684

8785
::CoUninitialize();
8886

89-
if (rc6.right > rc6.bottom)
90-
::SetWindowPos(tasklist, nullptr, def ? offset : Center + offset, 0, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_ASYNCWINDOWPOS);
91-
else
92-
::SetWindowPos(tasklist, nullptr, 0, def ? offset : Center + offset, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_ASYNCWINDOWPOS);
87+
if (justret != true)
88+
{
89+
if (rc6.right > rc6.bottom)
90+
::SetWindowPos(tasklist, nullptr, def ? offset : Center + offset, 0, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_ASYNCWINDOWPOS);
91+
else
92+
::SetWindowPos(tasklist, nullptr, 0, def ? offset : Center + offset, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_ASYNCWINDOWPOS);
93+
}
94+
95+
return Center + offset;
9396
}
9497

95-
9698
void SetTaskBarColor(HWND hWnd, COLORREF color, BYTE Alpha) noexcept
9799
{
98100
SetWindowBlur(hWnd, AccentState::ACCENT_ENABLE_GRADIENT, 0, color);

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55

66
----
77
## Features
8-
* Animations(beta)
9-
* calculates Center of taskbar
10-
* Vertical orientation support
8+
* Taskbar Animations
9+
* Calculates Center of Taskbar
10+
* Vertical Orientation Support
1111
* Change Taskbar Style, Color and Offset
1212
* Change StartMeu Style
1313
* Pick to Start On Boot

main.cpp

Lines changed: 141 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <ShellScalingAPI.h>
1010
#include <iostream>
1111
#include <thread>
12+
#include <vector>
1213

1314
#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' \
1415
processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
@@ -44,6 +45,8 @@ void WindowMessageLoop() noexcept
4445

4546
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
4647
{
48+
static int ItemIndex{};
49+
static TCHAR ListItem[256]{};
4750
static HWND h16 = NULL, h18 = NULL, h20 = NULL, h9 = NULL, h40 = NULL;
4851
static bool checked{};
4952

@@ -69,32 +72,158 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
6972

7073
HWND h11 = CreateWindow(TEXT("STATIC"), TEXT("TASKBAR POSITION"), WS_CHILD | WS_VISIBLE, 270, 30, 300, 25, hwnd, NULL, NULL, NULL);
7174
CreateWindow(TEXT("STATIC"), TEXT("OFFSET"), WS_CHILD | WS_VISIBLE, 270, 85, 300, 25, hwnd, NULL, NULL, NULL);
72-
h9 = CreateWindowEx(WS_EX_CLIENTEDGE, TEXT("EDIT"), TEXT("0"), WS_CHILD | WS_VISIBLE, 400, 80, 80, 25, hwnd, AutoCast<int>(12), NULL, NULL);
73-
74-
HWND h14 = CreateWindow(TEXT("STATIC"), TEXT("TASKBAR COLOR"), WS_CHILD | WS_VISIBLE, 270, 160, 300, 25, hwnd, NULL, NULL, NULL);
75-
CreateWindow(TEXT("STATIC"), TEXT("RED"), WS_CHILD | WS_VISIBLE, 270, 200, 300, 25, hwnd, NULL, NULL, NULL);
76-
h16 = CreateWindowEx(WS_EX_CLIENTEDGE, TEXT("EDIT"), TEXT("0"), WS_CHILD | WS_VISIBLE, 400, 200, 80, 25, hwnd, AutoCast<int>(19), NULL, NULL);
77-
CreateWindow(TEXT("STATIC"), TEXT("GREEN"), WS_CHILD | WS_VISIBLE, 270, 240, 300, 25, hwnd, NULL, NULL, NULL);
78-
h18 = CreateWindowEx(WS_EX_CLIENTEDGE, TEXT("EDIT"), TEXT("0"), WS_CHILD | WS_VISIBLE, 400, 240, 80, 25, hwnd, AutoCast<int>(20), NULL, NULL);
79-
CreateWindow(TEXT("STATIC"), TEXT("BLUE"), WS_CHILD | WS_VISIBLE, 270, 285, 300, 25, hwnd, NULL, NULL, NULL);
80-
h20 = CreateWindowEx(WS_EX_CLIENTEDGE, TEXT("EDIT"), TEXT("0"), WS_CHILD | WS_VISIBLE, 400, 285, 80, 25, hwnd, AutoCast<int>(21), NULL, NULL);
75+
h9 = CreateWindowEx(WS_EX_CLIENTEDGE, TEXT("EDIT"), TEXT("0"), WS_CHILD | WS_VISIBLE, 400, 80, 80, 25, hwnd, NULL, NULL, NULL);
76+
77+
HWND h14 = CreateWindow(TEXT("STATIC"), TEXT("TASKBAR COLOR"), WS_CHILD | WS_VISIBLE, 270, 140, 300, 25, hwnd, NULL, NULL, NULL);
78+
CreateWindow(TEXT("STATIC"), TEXT("RED"), WS_CHILD | WS_VISIBLE, 270, 180, 60, 25, hwnd, NULL, NULL, NULL);
79+
h16 = CreateWindowEx(WS_EX_CLIENTEDGE, TEXT("EDIT"), TEXT("0"), WS_CHILD | WS_VISIBLE, 270, 200, 60, 25, hwnd, NULL, NULL, NULL);
80+
CreateWindow(TEXT("STATIC"), TEXT("GREEN"), WS_CHILD | WS_VISIBLE, 350, 180, 60, 25, hwnd, NULL, NULL, NULL);
81+
h18 = CreateWindowEx(WS_EX_CLIENTEDGE, TEXT("EDIT"), TEXT("0"), WS_CHILD | WS_VISIBLE, 350, 200, 60, 25, hwnd, NULL, NULL, NULL);
82+
CreateWindow(TEXT("STATIC"), TEXT("BLUE"), WS_CHILD | WS_VISIBLE, 430, 180, 60, 25, hwnd, NULL, NULL, NULL);
83+
h20 = CreateWindowEx(WS_EX_CLIENTEDGE, TEXT("EDIT"), TEXT("0"), WS_CHILD | WS_VISIBLE, 430, 200, 60, 25, hwnd, NULL, NULL, NULL);
84+
85+
const HWND h223 = CreateWindow(TEXT("STATIC"), TEXT("ANIMATION"), WS_CHILD | WS_VISIBLE, 270, 260, 300, 25, hwnd, NULL, NULL, NULL);
86+
const HWND h224 = CreateWindow(TEXT("COMBOBOX"), TEXT("ComboBox"), CBS_DROPDOWN | WS_CHILD | WS_VISIBLE, 270, 290, 250, 0, hwnd, (HMENU)100, NULL, NULL);
87+
88+
std::vector<const wchar_t*> ComboBoxItems = {
89+
L"None", L"InOut Little", L"InOut Medium", L"InOut Alot", L"OutIn Little",
90+
L"OutIn Medium", L"OutIn Alot", L"OutOut Little", L"OutOut Medium", L"OutOut Alot",
91+
L"InIn Little", L"InIn Medium", L"InIn Alot"
92+
};
93+
94+
for (auto Item : ComboBoxItems)
95+
SendMessage(GetDlgItem(hwnd, 100), CB_ADDSTRING, 0, AutoCast<const wchar_t*>(Item));
96+
97+
SendMessage(h224, CB_SETCURSEL, 0, 0);
8198

8299
CreateWindow(TEXT("button"), TEXT("RESET"), WS_CHILD | WS_VISIBLE, 280, 400, 100, 35, hwnd, (HMENU)10003, NULL, NULL);
83100
CreateWindow(TEXT("button"), TEXT("APPLY"), WS_CHILD | WS_VISIBLE, 400, 400, 100, 35, hwnd, (HMENU)10002, NULL, NULL);
84101

85102
GUI_CREATEFONT(30, 12, "Arial", h11); GUI_CREATEFONT(30, 12, "Arial", h14); GUI_CREATEFONT(30, 12, "Arial", h1);
86103
GUI_CREATEFONT(30, 12, "Arial", h2); GUI_CREATEFONT(30, 12, "Arial", h3); GUI_CREATEFONT(30, 12, "Arial", h4);
87104
GUI_CREATEFONT(30, 12, "Arial", h5); GUI_CREATEFONT(30, 12, "Arial", h6); GUI_CREATEFONT(30, 12, "Arial", h100);
88-
GUI_CREATEFONT(30, 12, "Arial", h101); GUI_CREATEFONT(30, 12, "Arial", h103);
105+
GUI_CREATEFONT(30, 12, "Arial", h101); GUI_CREATEFONT(30, 12, "Arial", h103); GUI_CREATEFONT(30, 12, "Arial", h223);
106+
GUI_CREATEFONT(20, 9, "Arial", h224);
89107

90108
break;
91109
}
92110
case WM_COMMAND:
93111
{
112+
if (HIWORD(wParam) == CBN_SELCHANGE)
113+
{
114+
ItemIndex = SendMessage(AutoCast<LPARAM>(lParam), CB_GETCURSEL, 0, 0);
115+
116+
SendMessage(AutoCast<LPARAM>(lParam), CB_GETLBTEXT, ItemIndex,
117+
AutoCast<wchar_t*>(static_cast<wchar_t*>(ListItem)).ToAuto<LPARAM>());
118+
}
119+
94120
switch (LOWORD(wParam))
95121
{
96122
case 10002:
97123
{
124+
int lastCenter{};
125+
126+
while (true)
127+
{
128+
int center = CenterTaskBar(atoi(GetWinText(h9).c_str()), false, true);
129+
130+
if ((ItemIndex == 1))
131+
{
132+
if (center != lastCenter) // checks if a app is opend or closed
133+
{
134+
CreateAnimation(20, 40, atoi(GetWinText(h9).c_str()));
135+
}
136+
}
137+
if ((ItemIndex == 2))
138+
{
139+
if (center != lastCenter)
140+
{
141+
CreateAnimation(40, 80, atoi(GetWinText(h9).c_str()));
142+
}
143+
}
144+
if ((ItemIndex == 3))
145+
{
146+
if (center != lastCenter)
147+
{
148+
CreateAnimation(80, 100, atoi(GetWinText(h9).c_str()));
149+
}
150+
}
151+
if ((ItemIndex == 4))
152+
{
153+
if (center != lastCenter)
154+
{
155+
CreateAnimation(40, 20, atoi(GetWinText(h9).c_str()));
156+
}
157+
}
158+
if ((ItemIndex == 5))
159+
{
160+
if (center != lastCenter)
161+
{
162+
CreateAnimation(80, 40, atoi(GetWinText(h9).c_str()));
163+
}
164+
}
165+
if ((ItemIndex == 6))
166+
{
167+
if (center != lastCenter)
168+
{
169+
CreateAnimation(100, 80, atoi(GetWinText(h9).c_str()));
170+
}
171+
}
172+
if ((ItemIndex == 7))
173+
{
174+
if (center != lastCenter)
175+
{
176+
CreateAnimation(0, 20, atoi(GetWinText(h9).c_str()));
177+
}
178+
}
179+
if ((ItemIndex == 8))
180+
{
181+
if (center != lastCenter)
182+
{
183+
CreateAnimation(0, 40, atoi(GetWinText(h9).c_str()));
184+
}
185+
}
186+
if ((ItemIndex == 9))
187+
{
188+
if (center != lastCenter)
189+
{
190+
CreateAnimation(0, 80, atoi(GetWinText(h9).c_str()));
191+
}
192+
}
193+
if ((ItemIndex == 10))
194+
{
195+
if (center != lastCenter)
196+
{
197+
CreateAnimation(20, 0, atoi(GetWinText(h9).c_str()));
198+
}
199+
}
200+
if ((ItemIndex == 11))
201+
{
202+
if (center != lastCenter)
203+
{
204+
CreateAnimation(40, 0, atoi(GetWinText(h9).c_str()));
205+
}
206+
}
207+
if ((ItemIndex == 12))
208+
{
209+
if (center != lastCenter)
210+
{
211+
CreateAnimation(80, 0, atoi(GetWinText(h9).c_str()));
212+
}
213+
}
214+
if ((ItemIndex != 1) && (ItemIndex != 2) && (ItemIndex != 3) && (ItemIndex != 4) && (ItemIndex != 5) &&
215+
(ItemIndex != 6) && (ItemIndex != 7) && (ItemIndex != 8) && (ItemIndex != 9) &&
216+
(ItemIndex != 10) && (ItemIndex != 11) && (ItemIndex != 12))
217+
{
218+
break;
219+
}
220+
221+
lastCenter = center;
222+
223+
Sleep(10);
224+
WindowMessageLoop();
225+
}
226+
98227
if (IsDlgButtonChecked(hwnd, 10002) == BN_CLICKED)
99228
{
100229
while (true)
@@ -173,7 +302,7 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
173302
case WM_NOTIFY:
174303
{
175304
LPNMHDR some_item = AutoCast<LPARAM>(lParam);
176-
305+
177306
if (some_item->idFrom == 10002 || some_item->idFrom == 10003 && some_item->code == -12)
178307
{
179308
LPNMCUSTOMDRAW item = AutoCast<LPNMHDR>(some_item);
@@ -245,4 +374,4 @@ int WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE, _In_ LPSTR, _In
245374
}
246375

247376
return AutoCast<WPARAM>(msg.wParam).ToAuto<int>();
248-
}
377+
}

0 commit comments

Comments
 (0)