Replies: 1 comment
-
That's not an issue. Converted to a discussion. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
here is what i got
To avoid restarting the Explorer process when applying changes to the taskbar (like icon size), we need to dynamically update taskbar properties in memory without forcing Explorer to restart. Here's the general plan to achieve this:
Plan:
Direct Memory Manipulation or Hooks: Hook into the relevant Taskbar view model or window components and update properties like icon size directly in memory. This avoids requiring a restart by dynamically refreshing the UI.
Forcing Taskbar to Redraw/Refresh: Instead of restarting Explorer, we can force the Taskbar to refresh using Windows API calls like SHAppBarMessage or InvalidateRect.
Preserve Original State: Save the original settings to revert back if needed, without restarting Explorer.
Key Steps:
Use InvalidateRect or UpdateWindow: These can force the Taskbar to refresh without restarting Explorer.
Send SHAppBarMessage to refresh the Taskbar: The SHAppBarMessage function can be used to notify the system that the taskbar has changed.
Key Modifications:
RefreshTaskbar Function: Forces a redraw of the taskbar window and uses SHAppBarMessage to notify the system of changes, avoiding a restart.
ApplyDynamicSettings: Changes taskbar settings dynamically and then refreshes the taskbar using the methods above.
No Restart Required: This avoids restarting Explorer, updating the taskbar in real-time.
How to integrate this:
Call ApplyDynamicSettings() whenever the user changes a taskbar property like height or icon size.
Ensure that any hooks altering properties such as GetIconHeight also invoke the refresh logic.
#include <windows.h>
#include <shellapi.h>
// Global settings structure
struct Settings {
int taskbarHeight;
int taskbarButtonWidth;
} g_settings;
// Function prototypes
void ApplySettings(int newTaskbarHeight);
void RefreshTaskbar();
void ApplyDynamicSettings(int newTaskbarHeight);
void HookTaskbarIconHeight(double newIconHeight);
BOOL ModInitWithTaskbarView(HMODULE taskbarViewModule);
void Wh_ApplyHookOperations();
// Flag to check if the TaskbarView module is loaded
std::atomic g_taskbarViewDllLoaded = false;
// Apply the new settings dynamically without Explorer restart
void ApplyDynamicSettings(int newTaskbarHeight) {
// Apply the new taskbar height
g_settings.taskbarHeight = newTaskbarHeight;
}
// Force the taskbar to refresh without restarting Explorer
void RefreshTaskbar() {
HWND taskbarWnd = FindWindow(L"Shell_TrayWnd", NULL);
if (taskbarWnd) {
// Redraw taskbar
InvalidateRect(taskbarWnd, NULL, TRUE);
UpdateWindow(taskbarWnd);
}
}
// Example hook setup for changing taskbar icon height
void HookTaskbarIconHeight(double newIconHeight) {
if (g_taskbarViewDllLoaded) {
ApplySettings(newIconHeight); // Hook to apply new height
RefreshTaskbar(); // Refresh taskbar to reflect changes
}
}
void Wh_ModAfterInit() {
Wh_Log(L">");
}
void Wh_ModBeforeUninit() {
Wh_Log(L">");
}
void Wh_ModSettingsChanged() {
Wh_Log(L">");
}
void Wh_ModUninit() {
Wh_Log(L">");
}
Beta Was this translation helpful? Give feedback.
All reactions