1
0
mirror of https://github.com/valinet/ExplorerPatcher.git synced 2024-11-30 18:24:36 +01:00

Created notification for taskbar layout updates

This commit is contained in:
Valentin Radu 2021-10-03 06:07:20 +03:00
parent b177b49743
commit 6c72c7a15d
5 changed files with 74 additions and 0 deletions

View File

@ -203,6 +203,7 @@
<ClCompile Include="StartMenu.c" />
<ClCompile Include="StartupSound.c" />
<ClCompile Include="symbols.c" />
<ClCompile Include="TaskbarCenter.c" />
<ClCompile Include="utility.c" />
</ItemGroup>
<ItemGroup>
@ -218,6 +219,7 @@
<ClInclude Include="StartMenu.h" />
<ClInclude Include="StartupSound.h" />
<ClInclude Include="symbols.h" />
<ClInclude Include="TaskbarCenter.h" />
<ClInclude Include="utility.h" />
</ItemGroup>
<ItemGroup>

View File

@ -54,6 +54,9 @@
<ClInclude Include="fmemopen.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="TaskbarCenter.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="ExplorerPatcher.rc">
@ -94,6 +97,9 @@
<ClCompile Include="fmemopen.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="TaskbarCenter.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="settings.reg" />

View File

@ -0,0 +1,43 @@
#include "TaskbarCenter.h"
HANDLE hEvent;
BOOL TaskbarCenter_Notify()
{
if (hEvent)
{
SetEvent(hEvent);
return TRUE;
}
return FALSE;
}
BOOL GetClientRectHook(HWND hWnd, LPRECT lpRect)
{
wchar_t wszClassName[100];
ZeroMemory(wszClassName, 100);
GetClassNameW(hWnd, wszClassName, 100);
if (!wcscmp(wszClassName, L"Shell_TrayWnd") || !wcscmp(wszClassName, L"Shell_SecondaryTrayWnd"))
{
TaskbarCenter_Notify();
}
return GetClientRect(hWnd, lpRect);
}
HRESULT TaskbarCenter_Initialize(HMODULE hExplorer)
{
// This is one of the methods called by explorer!CTaskListWnd::_RecomputeLayout
if (!VnPatchDelayIAT(hExplorer, "ext-ms-win-rtcore-ntuser-window-ext-l1-1-0.dll", "GetClientRect", GetClientRectHook))
{
return E_NOTIMPL;
}
if (!(hEvent = CreateEventW(NULL, TRUE, FALSE, TASKBAR_CHANGED_NOTIFICATION)))
{
return E_NOTIMPL;
}
if (GetLastError() == ERROR_ALREADY_EXISTS)
{
return E_NOTIMPL;
}
return S_OK;
}

View File

@ -0,0 +1,10 @@
#ifndef _H_TASKBARCENTER_H_
#define _H_TASKBARCENTER_H_
#include <initguid.h>
#include <Windows.h>
#include <valinet/hooking/iatpatch.h>
#define TASKBAR_CHANGED_NOTIFICATION L"Global\\ExplorerPatcher_TaskbarChangedNotification"
HRESULT TaskbarCenter_Initialize(HMODULE);
#endif

View File

@ -28,6 +28,7 @@
#include "HideExplorerSearchBar.h"
#include "StartMenu.h"
#include "GUI.h"
#include "TaskbarCenter.h"
#define WINX_ADJUST_X 5
#define WINX_ADJUST_Y 5
@ -1549,9 +1550,21 @@ __declspec(dllexport) DWORD WINAPI main(
ArchiveMenuThread,
params,
0,
0,
0
);
}
// This notifies applications when the taskbar has recomputed its layout
if (SUCCEEDED(TaskbarCenter_Initialize(hExplorer)))
{
printf("Initialized taskbar update notification.\n");
}
else
{
printf("Failed to register taskbar update notification.\n");
}
}
else
{