Skip to content

Commit

Permalink
Added
Browse files Browse the repository at this point in the history
  • Loading branch information
Duui3111 committed Mar 24, 2021
1 parent 6708085 commit 284e1d3
Show file tree
Hide file tree
Showing 5 changed files with 160 additions and 24 deletions.
1 change: 1 addition & 0 deletions BetterTaskbar.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@
</ItemGroup>
<ItemGroup>
<Image Include="Resources\icon.ico" />
<Image Include="Resources\taskbar.gif" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="Resources\Resource.rc" />
Expand Down
6 changes: 5 additions & 1 deletion Headers/AutoCast.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ class AutoCast
{
public:
explicit AutoCast(T any) noexcept : _any(any) {}
template <typename T> T ToAuto() noexcept { return T(_any); }
template <typename T> T ToAuto() noexcept { return (T)_any; }
template <typename T> T ToStatic() noexcept { return static_cast<T>(_any); }
template <typename T> T ToConst() noexcept { return const_cast<T>(_any); }
template <typename T> T ToReinterpret() noexcept { return reinterpret_cast<T>(_any); }
template <typename T> operator T*() const noexcept { return (T*)_any; }
template <typename T> operator T() const noexcept { return (T)_any; }

private:
T _any;
Expand Down
18 changes: 10 additions & 8 deletions Headers/Taskbar.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,8 @@ void SetWindowBlur(HWND hWnd, AccentState AccentState, int Flags = 2, int color
}
}

void CenterTaskBar(int offset, bool def = false)
int CenterTaskBar(int offset, bool def = false, bool justret = false)
{
//const int result = SetProcessDpiAwareness(PROCESS_PER_MONITOR_DPI_AWARE);

HWND taskbar = FindWindowA("Shell_TrayWnd", NULL);
HWND panel = FindWindowExA(taskbar, NULL, "ReBarWindow32", NULL);
HWND panel2 = FindWindowExA(panel, NULL, "MSTaskSwWClass", NULL);
Expand Down Expand Up @@ -86,13 +84,17 @@ void CenterTaskBar(int offset, bool def = false)

::CoUninitialize();

if (rc6.right > rc6.bottom)
::SetWindowPos(tasklist, nullptr, def ? offset : Center + offset, 0, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_ASYNCWINDOWPOS);
else
::SetWindowPos(tasklist, nullptr, 0, def ? offset : Center + offset, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_ASYNCWINDOWPOS);
if (justret != true)
{
if (rc6.right > rc6.bottom)
::SetWindowPos(tasklist, nullptr, def ? offset : Center + offset, 0, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_ASYNCWINDOWPOS);
else
::SetWindowPos(tasklist, nullptr, 0, def ? offset : Center + offset, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_ASYNCWINDOWPOS);
}

return Center + offset;
}


void SetTaskBarColor(HWND hWnd, COLORREF color, BYTE Alpha) noexcept
{
SetWindowBlur(hWnd, AccentState::ACCENT_ENABLE_GRADIENT, 0, color);
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

----
## Features
* Animations(beta)
* calculates Center of taskbar
* Vertical orientation support
* Taskbar Animations
* Calculates Center of Taskbar
* Vertical Orientation Support
* Change Taskbar Style, Color and Offset
* Change StartMeu Style
* Pick to Start On Boot
Expand Down
153 changes: 141 additions & 12 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <ShellScalingAPI.h>
#include <iostream>
#include <thread>
#include <vector>

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

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

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

HWND h11 = CreateWindow(TEXT("STATIC"), TEXT("TASKBAR POSITION"), WS_CHILD | WS_VISIBLE, 270, 30, 300, 25, hwnd, NULL, NULL, NULL);
CreateWindow(TEXT("STATIC"), TEXT("OFFSET"), WS_CHILD | WS_VISIBLE, 270, 85, 300, 25, hwnd, NULL, NULL, NULL);
h9 = CreateWindowEx(WS_EX_CLIENTEDGE, TEXT("EDIT"), TEXT("0"), WS_CHILD | WS_VISIBLE, 400, 80, 80, 25, hwnd, AutoCast<int>(12), NULL, NULL);

HWND h14 = CreateWindow(TEXT("STATIC"), TEXT("TASKBAR COLOR"), WS_CHILD | WS_VISIBLE, 270, 160, 300, 25, hwnd, NULL, NULL, NULL);
CreateWindow(TEXT("STATIC"), TEXT("RED"), WS_CHILD | WS_VISIBLE, 270, 200, 300, 25, hwnd, NULL, NULL, NULL);
h16 = CreateWindowEx(WS_EX_CLIENTEDGE, TEXT("EDIT"), TEXT("0"), WS_CHILD | WS_VISIBLE, 400, 200, 80, 25, hwnd, AutoCast<int>(19), NULL, NULL);
CreateWindow(TEXT("STATIC"), TEXT("GREEN"), WS_CHILD | WS_VISIBLE, 270, 240, 300, 25, hwnd, NULL, NULL, NULL);
h18 = CreateWindowEx(WS_EX_CLIENTEDGE, TEXT("EDIT"), TEXT("0"), WS_CHILD | WS_VISIBLE, 400, 240, 80, 25, hwnd, AutoCast<int>(20), NULL, NULL);
CreateWindow(TEXT("STATIC"), TEXT("BLUE"), WS_CHILD | WS_VISIBLE, 270, 285, 300, 25, hwnd, NULL, NULL, NULL);
h20 = CreateWindowEx(WS_EX_CLIENTEDGE, TEXT("EDIT"), TEXT("0"), WS_CHILD | WS_VISIBLE, 400, 285, 80, 25, hwnd, AutoCast<int>(21), NULL, NULL);
h9 = CreateWindowEx(WS_EX_CLIENTEDGE, TEXT("EDIT"), TEXT("0"), WS_CHILD | WS_VISIBLE, 400, 80, 80, 25, hwnd, NULL, NULL, NULL);

HWND h14 = CreateWindow(TEXT("STATIC"), TEXT("TASKBAR COLOR"), WS_CHILD | WS_VISIBLE, 270, 140, 300, 25, hwnd, NULL, NULL, NULL);
CreateWindow(TEXT("STATIC"), TEXT("RED"), WS_CHILD | WS_VISIBLE, 270, 180, 60, 25, hwnd, NULL, NULL, NULL);
h16 = CreateWindowEx(WS_EX_CLIENTEDGE, TEXT("EDIT"), TEXT("0"), WS_CHILD | WS_VISIBLE, 270, 200, 60, 25, hwnd, NULL, NULL, NULL);
CreateWindow(TEXT("STATIC"), TEXT("GREEN"), WS_CHILD | WS_VISIBLE, 350, 180, 60, 25, hwnd, NULL, NULL, NULL);
h18 = CreateWindowEx(WS_EX_CLIENTEDGE, TEXT("EDIT"), TEXT("0"), WS_CHILD | WS_VISIBLE, 350, 200, 60, 25, hwnd, NULL, NULL, NULL);
CreateWindow(TEXT("STATIC"), TEXT("BLUE"), WS_CHILD | WS_VISIBLE, 430, 180, 60, 25, hwnd, NULL, NULL, NULL);
h20 = CreateWindowEx(WS_EX_CLIENTEDGE, TEXT("EDIT"), TEXT("0"), WS_CHILD | WS_VISIBLE, 430, 200, 60, 25, hwnd, NULL, NULL, NULL);

const HWND h223 = CreateWindow(TEXT("STATIC"), TEXT("ANIMATION"), WS_CHILD | WS_VISIBLE, 270, 260, 300, 25, hwnd, NULL, NULL, NULL);
const HWND h224 = CreateWindow(TEXT("COMBOBOX"), TEXT("ComboBox"), CBS_DROPDOWN | WS_CHILD | WS_VISIBLE, 270, 290, 250, 0, hwnd, (HMENU)100, NULL, NULL);

std::vector<const wchar_t*> ComboBoxItems = {
L"None", L"InOut Little", L"InOut Medium", L"InOut Alot", L"OutIn Little",
L"OutIn Medium", L"OutIn Alot", L"OutOut Little", L"OutOut Medium", L"OutOut Alot",
L"InIn Little", L"InIn Medium", L"InIn Alot"
};

for (auto Item : ComboBoxItems)
SendMessage(GetDlgItem(hwnd, 100), CB_ADDSTRING, 0, AutoCast<const wchar_t*>(Item));

SendMessage(h224, CB_SETCURSEL, 0, 0);

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

GUI_CREATEFONT(30, 12, "Arial", h11); GUI_CREATEFONT(30, 12, "Arial", h14); GUI_CREATEFONT(30, 12, "Arial", h1);
GUI_CREATEFONT(30, 12, "Arial", h2); GUI_CREATEFONT(30, 12, "Arial", h3); GUI_CREATEFONT(30, 12, "Arial", h4);
GUI_CREATEFONT(30, 12, "Arial", h5); GUI_CREATEFONT(30, 12, "Arial", h6); GUI_CREATEFONT(30, 12, "Arial", h100);
GUI_CREATEFONT(30, 12, "Arial", h101); GUI_CREATEFONT(30, 12, "Arial", h103);
GUI_CREATEFONT(30, 12, "Arial", h101); GUI_CREATEFONT(30, 12, "Arial", h103); GUI_CREATEFONT(30, 12, "Arial", h223);
GUI_CREATEFONT(20, 9, "Arial", h224);

break;
}
case WM_COMMAND:
{
if (HIWORD(wParam) == CBN_SELCHANGE)
{
ItemIndex = SendMessage(AutoCast<LPARAM>(lParam), CB_GETCURSEL, 0, 0);

SendMessage(AutoCast<LPARAM>(lParam), CB_GETLBTEXT, ItemIndex,
AutoCast<wchar_t*>(static_cast<wchar_t*>(ListItem)).ToAuto<LPARAM>());
}

switch (LOWORD(wParam))
{
case 10002:
{
int lastCenter{};

while (true)
{
int center = CenterTaskBar(atoi(GetWinText(h9).c_str()), false, true);

if ((ItemIndex == 1))
{
if (center != lastCenter) // checks if a app is opend or closed
{
CreateAnimation(20, 40, atoi(GetWinText(h9).c_str()));
}
}
if ((ItemIndex == 2))
{
if (center != lastCenter)
{
CreateAnimation(40, 80, atoi(GetWinText(h9).c_str()));
}
}
if ((ItemIndex == 3))
{
if (center != lastCenter)
{
CreateAnimation(80, 100, atoi(GetWinText(h9).c_str()));
}
}
if ((ItemIndex == 4))
{
if (center != lastCenter)
{
CreateAnimation(40, 20, atoi(GetWinText(h9).c_str()));
}
}
if ((ItemIndex == 5))
{
if (center != lastCenter)
{
CreateAnimation(80, 40, atoi(GetWinText(h9).c_str()));
}
}
if ((ItemIndex == 6))
{
if (center != lastCenter)
{
CreateAnimation(100, 80, atoi(GetWinText(h9).c_str()));
}
}
if ((ItemIndex == 7))
{
if (center != lastCenter)
{
CreateAnimation(0, 20, atoi(GetWinText(h9).c_str()));
}
}
if ((ItemIndex == 8))
{
if (center != lastCenter)
{
CreateAnimation(0, 40, atoi(GetWinText(h9).c_str()));
}
}
if ((ItemIndex == 9))
{
if (center != lastCenter)
{
CreateAnimation(0, 80, atoi(GetWinText(h9).c_str()));
}
}
if ((ItemIndex == 10))
{
if (center != lastCenter)
{
CreateAnimation(20, 0, atoi(GetWinText(h9).c_str()));
}
}
if ((ItemIndex == 11))
{
if (center != lastCenter)
{
CreateAnimation(40, 0, atoi(GetWinText(h9).c_str()));
}
}
if ((ItemIndex == 12))
{
if (center != lastCenter)
{
CreateAnimation(80, 0, atoi(GetWinText(h9).c_str()));
}
}
if ((ItemIndex != 1) && (ItemIndex != 2) && (ItemIndex != 3) && (ItemIndex != 4) && (ItemIndex != 5) &&
(ItemIndex != 6) && (ItemIndex != 7) && (ItemIndex != 8) && (ItemIndex != 9) &&
(ItemIndex != 10) && (ItemIndex != 11) && (ItemIndex != 12))
{
break;
}

lastCenter = center;

Sleep(10);
WindowMessageLoop();
}

if (IsDlgButtonChecked(hwnd, 10002) == BN_CLICKED)
{
while (true)
Expand Down Expand Up @@ -173,7 +302,7 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
case WM_NOTIFY:
{
LPNMHDR some_item = AutoCast<LPARAM>(lParam);

if (some_item->idFrom == 10002 || some_item->idFrom == 10003 && some_item->code == -12)
{
LPNMCUSTOMDRAW item = AutoCast<LPNMHDR>(some_item);
Expand Down Expand Up @@ -245,4 +374,4 @@ int WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE, _In_ LPSTR, _In
}

return AutoCast<WPARAM>(msg.wParam).ToAuto<int>();
}
}

0 comments on commit 284e1d3

Please sign in to comment.