Classic Theme Explorer: QtTabBar fixes
This commit is contained in:
		
							parent
							
								
									e290872724
								
							
						
					
					
						commit
						3969dbbb43
					
				
					 1 changed files with 43 additions and 15 deletions
				
			
		| 
						 | 
					@ -116,7 +116,28 @@ HWND GetChildWindow(HWND parent, const wchar_t* className, int index)
 | 
				
			||||||
    return data.result;
 | 
					    return data.result;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
VOID ClassicThemeExplorer(HWND hWnd, WPARAM wParam)
 | 
					// QtTabBar's hooking taints the wParam for some reason, so we strip off the extra bits if needed.
 | 
				
			||||||
 | 
					BOOL ShouldApply(WPARAM wParam, BOOL fallback, BOOL checkSix) {
 | 
				
			||||||
 | 
					    Wh_Log(L"0x%x, %d", wParam, fallback);
 | 
				
			||||||
 | 
					    if (wParam > 0xffff) {
 | 
				
			||||||
 | 
					        Wh_Log(L"above 0xffff");
 | 
				
			||||||
 | 
					        if ((wParam & 1) == 1) {
 | 
				
			||||||
 | 
					            Wh_Log(L"1 set");
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					        } else if (checkSix && (wParam & 6) == 6) {
 | 
				
			||||||
 | 
					            Wh_Log(L"6 set");
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            Wh_Log(L"falling back");
 | 
				
			||||||
 | 
					            return fallback;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					        Wh_Log(L"falling back");
 | 
				
			||||||
 | 
					        return fallback;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					VOID ClassicThemeExplorer(HWND hWnd, UINT uMsg, WPARAM wParam)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    wchar_t classNameBuffer[256];
 | 
					    wchar_t classNameBuffer[256];
 | 
				
			||||||
    wchar_t pathBuffer[MAX_PATH];
 | 
					    wchar_t pathBuffer[MAX_PATH];
 | 
				
			||||||
| 
						 | 
					@ -131,7 +152,11 @@ VOID ClassicThemeExplorer(HWND hWnd, WPARAM wParam)
 | 
				
			||||||
    HWND ClassicComboBox = GetChildWindow(ClassicAddressBandRoot, L"ComboBoxEx32", 1);
 | 
					    HWND ClassicComboBox = GetChildWindow(ClassicAddressBandRoot, L"ComboBoxEx32", 1);
 | 
				
			||||||
    HWND ClassicRebar = GetChildWindow((HWND)hWnd, L"ReBarWindow32", 2);
 | 
					    HWND ClassicRebar = GetChildWindow((HWND)hWnd, L"ReBarWindow32", 2);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (settings.clientEdge && (wParam == 1 || wParam == 6)) {
 | 
					    BOOL shouldApply = uMsg == WM_PARENTNOTIFY && ShouldApply(wParam, wParam == 1 || wParam == 6, false);
 | 
				
			||||||
 | 
					    BOOL shouldApply2 = uMsg == WM_PARENTNOTIFY && ShouldApply(wParam, wParam == 1, true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (settings.clientEdge && shouldApply) {
 | 
				
			||||||
 | 
					        Wh_Log(L"applying client edge");
 | 
				
			||||||
        HWND TreeView = GetChildWindow((HWND)hWnd, L"SysTreeView32", 1);
 | 
					        HWND TreeView = GetChildWindow((HWND)hWnd, L"SysTreeView32", 1);
 | 
				
			||||||
        LONG TreeViewExtendedStyle = GetWindowLongPtrW(TreeView, GWL_EXSTYLE);
 | 
					        LONG TreeViewExtendedStyle = GetWindowLongPtrW(TreeView, GWL_EXSTYLE);
 | 
				
			||||||
        TreeViewExtendedStyle |= WS_EX_CLIENTEDGE;
 | 
					        TreeViewExtendedStyle |= WS_EX_CLIENTEDGE;
 | 
				
			||||||
| 
						 | 
					@ -148,27 +173,29 @@ VOID ClassicThemeExplorer(HWND hWnd, WPARAM wParam)
 | 
				
			||||||
        SetWindowPos(ShellTabWindowClass, NULL, NULL, NULL, rect.right - rect.left, rect.bottom - rect.top, SWP_NOMOVE | SWP_NOZORDER | SWP_DEFERERASE);
 | 
					        SetWindowPos(ShellTabWindowClass, NULL, NULL, NULL, rect.right - rect.left, rect.bottom - rect.top, SWP_NOMOVE | SWP_NOZORDER | SWP_DEFERERASE);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (settings.rebarBorder && (wParam == 1 || wParam == 6)) {
 | 
					    if (settings.rebarBorder && shouldApply) {
 | 
				
			||||||
 | 
					        Wh_Log(L"applying rebar border");
 | 
				
			||||||
        LONG ClassicRebarStyle = GetWindowLongPtrW(ClassicRebar, GWL_STYLE);
 | 
					        LONG ClassicRebarStyle = GetWindowLongPtrW(ClassicRebar, GWL_STYLE);
 | 
				
			||||||
        ClassicRebarStyle |= RBS_BANDBORDERS;
 | 
					        ClassicRebarStyle |= RBS_BANDBORDERS;
 | 
				
			||||||
        ClassicRebarStyle |= WS_BORDER;
 | 
					        ClassicRebarStyle |= WS_BORDER;
 | 
				
			||||||
        SetWindowLongPtrW(ClassicRebar, GWL_STYLE, ClassicRebarStyle);
 | 
					        SetWindowLongPtrW(ClassicRebar, GWL_STYLE, ClassicRebarStyle);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (settings.rebarFixedHeight && (wParam == 1 || wParam == 6)) {
 | 
					    if (settings.rebarFixedHeight && shouldApply) {
 | 
				
			||||||
 | 
					        Wh_Log(L"applying rebar fixed height");
 | 
				
			||||||
        LONG ClassicRebarStyle = GetWindowLongPtrW(ClassicRebar, GWL_STYLE);
 | 
					        LONG ClassicRebarStyle = GetWindowLongPtrW(ClassicRebar, GWL_STYLE);
 | 
				
			||||||
        ClassicRebarStyle &= ~RBS_VARHEIGHT;
 | 
					        ClassicRebarStyle &= ~RBS_VARHEIGHT;
 | 
				
			||||||
        SetWindowLongPtrW(ClassicRebar, GWL_STYLE, ClassicRebarStyle);
 | 
					        SetWindowLongPtrW(ClassicRebar, GWL_STYLE, ClassicRebarStyle);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Apply bar changes
 | 
					    // Apply bar changes
 | 
				
			||||||
    if ((settings.rebarBorder || settings.rebarFixedHeight) && (wParam == 1 || wParam == 6)) {
 | 
					    if ((settings.rebarBorder || settings.rebarFixedHeight) && shouldApply) {
 | 
				
			||||||
        GetWindowRect(ClassicRebar, &rect);
 | 
					        GetWindowRect(ClassicRebar, &rect);
 | 
				
			||||||
        SetWindowPos(ClassicRebar, NULL, NULL, NULL, rect.right - rect.left + 1, rect.bottom - rect.top, SWP_NOMOVE | SWP_NOZORDER | SWP_DEFERERASE);
 | 
					        SetWindowPos(ClassicRebar, NULL, NULL, NULL, rect.right - rect.left + 1, rect.bottom - rect.top, SWP_NOMOVE | SWP_NOZORDER | SWP_DEFERERASE);
 | 
				
			||||||
        SetWindowPos(ClassicRebar, NULL, NULL, NULL, rect.right - rect.left, rect.bottom - rect.top, SWP_NOMOVE | SWP_NOZORDER | SWP_DEFERERASE);
 | 
					        SetWindowPos(ClassicRebar, NULL, NULL, NULL, rect.right - rect.left, rect.bottom - rect.top, SWP_NOMOVE | SWP_NOZORDER | SWP_DEFERERASE);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (settings.hideNavigation && wParam == 1) {
 | 
					    if (settings.hideNavigation && shouldApply2) {
 | 
				
			||||||
        // Save the location of the Rebar
 | 
					        // Save the location of the Rebar
 | 
				
			||||||
        HWND NavBarRebar = GetChildWindow((HWND)hWnd, L"ReBarWindow32", 1);
 | 
					        HWND NavBarRebar = GetChildWindow((HWND)hWnd, L"ReBarWindow32", 1);
 | 
				
			||||||
        GetWindowRect(NavBarRebar, &rect);
 | 
					        GetWindowRect(NavBarRebar, &rect);
 | 
				
			||||||
| 
						 | 
					@ -212,10 +239,11 @@ VOID ClassicThemeExplorer(HWND hWnd, WPARAM wParam)
 | 
				
			||||||
            HWND toolbarwindow = GetChildWindow(NavBarAddressBandRoot, L"ToolbarWindow32", 1);
 | 
					            HWND toolbarwindow = GetChildWindow(NavBarAddressBandRoot, L"ToolbarWindow32", 1);
 | 
				
			||||||
            GetWindowTextW(toolbarwindow, pathBuffer, MAX_PATH);
 | 
					            GetWindowTextW(toolbarwindow, pathBuffer, MAX_PATH);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // remove "Address: "
 | 
					            // FIXME: codecvt deprecated as of c++17
 | 
				
			||||||
            // FIXME: locale issues, codecvt deprecated as of c++17
 | 
					 | 
				
			||||||
            std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
 | 
					            std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // remove "Address: "
 | 
				
			||||||
 | 
					            // FIXME: support more locales
 | 
				
			||||||
            std::wstring _pathStr = pathBuffer;
 | 
					            std::wstring _pathStr = pathBuffer;
 | 
				
			||||||
            std::string pathStr(_pathStr.begin(), _pathStr.end());
 | 
					            std::string pathStr(_pathStr.begin(), _pathStr.end());
 | 
				
			||||||
            pathStr = std::regex_replace(pathStr, std::regex("Address: "), "");
 | 
					            pathStr = std::regex_replace(pathStr, std::regex("Address: "), "");
 | 
				
			||||||
| 
						 | 
					@ -233,7 +261,7 @@ VOID ClassicThemeExplorer(HWND hWnd, WPARAM wParam)
 | 
				
			||||||
        // TODO: figure out how to get and set folder icon
 | 
					        // TODO: figure out how to get and set folder icon
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (settings.hideRefresh && (wParam == 1 || wParam == 6)) {
 | 
					    if (settings.hideRefresh && shouldApply) {
 | 
				
			||||||
        HWND GoButtonToolbar = GetChildWindow(ClassicAddressBandRoot, L"ToolbarWindow32", 1);
 | 
					        HWND GoButtonToolbar = GetChildWindow(ClassicAddressBandRoot, L"ToolbarWindow32", 1);
 | 
				
			||||||
        SendMessageW(GoButtonToolbar, WM_CLOSE, 0, 0);
 | 
					        SendMessageW(GoButtonToolbar, WM_CLOSE, 0, 0);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					@ -333,14 +361,14 @@ UINT g_subclassRegisteredMsg = RegisterWindowMessage(L"Windhawk_SetWindowSubclas
 | 
				
			||||||
 | 
					
 | 
				
			||||||
LRESULT CALLBACK ClassicThemeExplorerSubClass(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData) {
 | 
					LRESULT CALLBACK ClassicThemeExplorerSubClass(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData) {
 | 
				
			||||||
    if (uMsg == WM_DESTROY) {
 | 
					    if (uMsg == WM_DESTROY) {
 | 
				
			||||||
        //Wh_Log(L"[Destroy] uMsg: 0x%04x, wParam: 0x%x", uMsg, wParam);
 | 
					        Wh_Log(L"[Destroy] uMsg: 0x%04x, wParam: 0x%x", uMsg, wParam);
 | 
				
			||||||
        RemoveWindowSubclass(hWnd, ClassicThemeExplorerSubClass, 0);
 | 
					        RemoveWindowSubclass(hWnd, ClassicThemeExplorerSubClass, 0);
 | 
				
			||||||
    } else if (uMsg == g_subclassRegisteredMsg && !wParam) {
 | 
					    } else if (uMsg == g_subclassRegisteredMsg && !wParam) {
 | 
				
			||||||
        //Wh_Log(L"[Unsub] uMsg: 0x%04x, wParam: 0x%x", uMsg, wParam);
 | 
					        Wh_Log(L"[Unsub] uMsg: 0x%04x, wParam: 0x%x", uMsg, wParam);
 | 
				
			||||||
        RemoveWindowSubclass(hWnd, ClassicThemeExplorerSubClass, 0);
 | 
					        RemoveWindowSubclass(hWnd, ClassicThemeExplorerSubClass, 0);
 | 
				
			||||||
    } else if (uMsg == WM_PARENTNOTIFY || uMsg == WM_SIZE || uMsg == WM_GETICON) {
 | 
					    } else if (uMsg == WM_PARENTNOTIFY || uMsg == WM_SIZE || uMsg == WM_GETICON) {
 | 
				
			||||||
        //Wh_Log(L"[Target] uMsg: 0x%04x, wParam: 0x%x", uMsg, wParam);
 | 
					        Wh_Log(L"[Target] uMsg: 0x%04x, wParam: 0x%x", uMsg, wParam);
 | 
				
			||||||
        ClassicThemeExplorer(hWnd, wParam);
 | 
					        ClassicThemeExplorer(hWnd, uMsg, wParam);
 | 
				
			||||||
    //} else {
 | 
					    //} else {
 | 
				
			||||||
        //Wh_Log(L"[Unknown] uMsg: 0x%04x, wParam: 0x%x", uMsg, wParam);
 | 
					        //Wh_Log(L"[Unknown] uMsg: 0x%04x, wParam: 0x%x", uMsg, wParam);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					@ -405,7 +433,7 @@ HWND WINAPI SHCreateWorkerWindowHook(WNDPROC wndProc, HWND hWndParent, DWORD dwE
 | 
				
			||||||
    LSTATUS lRes = ERROR_FILE_NOT_FOUND;
 | 
					    LSTATUS lRes = ERROR_FILE_NOT_FOUND;
 | 
				
			||||||
    DWORD dwSize = 0;
 | 
					    DWORD dwSize = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    //Wh_Log("g_uiThreadId: %d, GetCurrentThreadId: %d", g_uiThreadId, GetCurrentThreadId());
 | 
					    Wh_Log(L"g_uiThreadId: %d, GetCurrentThreadId: %d", g_uiThreadId, GetCurrentThreadId());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // is this even needed? it changes thread after some time anyways
 | 
					    // is this even needed? it changes thread after some time anyways
 | 
				
			||||||
    //if (g_uiThreadId && g_uiThreadId != GetCurrentThreadId()) return pOriginalSHCreateWorkerWindow(wndProc, hWndParent, dwExStyle, dwStyle, hMenu, wnd_extra);
 | 
					    //if (g_uiThreadId && g_uiThreadId != GetCurrentThreadId()) return pOriginalSHCreateWorkerWindow(wndProc, hWndParent, dwExStyle, dwStyle, hMenu, wnd_extra);
 | 
				
			||||||
| 
						 | 
					@ -422,7 +450,7 @@ HWND WINAPI SHCreateWorkerWindowHook(WNDPROC wndProc, HWND hWndParent, DWORD dwE
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    else result = pOriginalSHCreateWorkerWindow(wndProc, hWndParent, dwExStyle, dwStyle, hMenu, wnd_extra);
 | 
					    else result = pOriginalSHCreateWorkerWindow(wndProc, hWndParent, dwExStyle, dwStyle, hMenu, wnd_extra);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    //Wh_Log("dwExStyle: 0x%x, dwStyle: 0x%x, result: 0x%x", dwExStyle, dwStyle, result);
 | 
					    Wh_Log(L"dwExStyle: 0x%x, dwStyle: 0x%x, result: 0x%x", dwExStyle, dwStyle, result);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (dwExStyle == 0x10000 && dwStyle == 0x46000000 && result) SetWindowSubclassFromAnyThread(hWndParent, ClassicThemeExplorerSubClass, 0, 0);
 | 
					    if (dwExStyle == 0x10000 && dwStyle == 0x46000000 && result) SetWindowSubclassFromAnyThread(hWndParent, ClassicThemeExplorerSubClass, 0, 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue