Browse Source

Created notification for taskbar layout updates

pull/51/head
Valentin Radu 4 years ago
parent
commit
6c72c7a15d
  1. 2
      ExplorerPatcher/ExplorerPatcher.vcxproj
  2. 6
      ExplorerPatcher/ExplorerPatcher.vcxproj.filters
  3. 43
      ExplorerPatcher/TaskbarCenter.c
  4. 10
      ExplorerPatcher/TaskbarCenter.h
  5. 13
      ExplorerPatcher/dllmain.c

2
ExplorerPatcher/ExplorerPatcher.vcxproj

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

6
ExplorerPatcher/ExplorerPatcher.vcxproj.filters

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

43
ExplorerPatcher/TaskbarCenter.c

@ -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;
}

10
ExplorerPatcher/TaskbarCenter.h

@ -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

13
ExplorerPatcher/dllmain.c

@ -28,6 +28,7 @@
#include "HideExplorerSearchBar.h" #include "HideExplorerSearchBar.h"
#include "StartMenu.h" #include "StartMenu.h"
#include "GUI.h" #include "GUI.h"
#include "TaskbarCenter.h"
#define WINX_ADJUST_X 5 #define WINX_ADJUST_X 5
#define WINX_ADJUST_Y 5 #define WINX_ADJUST_Y 5
@ -1549,9 +1550,21 @@ __declspec(dllexport) DWORD WINAPI main(
ArchiveMenuThread, ArchiveMenuThread,
params, params,
0, 0,
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 else
{ {

Loading…
Cancel
Save