diff --git a/.mingw/Makefile.am b/.mingw/Makefile.am index 2326c9ca..cb131d61 100644 --- a/.mingw/Makefile.am +++ b/.mingw/Makefile.am @@ -19,7 +19,7 @@ TARGET := $(word 1,$(subst -, ,$(TUPLE))) DEF_SUFFIX := $(if $(TARGET:x86_64=),.def,.def64) .PHONY: all -all: dwmapi-delaylib.lib version-delaylib.lib wintrust-delaylib.lib uxtheme-delaylib.lib +all: dwmapi-delaylib.lib version-delaylib.lib wintrust-delaylib.lib %.def64: %.def $(AM_V_SED) "s/@.*//" $< >$@ diff --git a/.mingw/Makefile.in b/.mingw/Makefile.in index 877c4d83..0dda8fb1 100644 --- a/.mingw/Makefile.in +++ b/.mingw/Makefile.in @@ -367,7 +367,7 @@ uninstall-am: .PHONY: all -all: dwmapi-delaylib.lib version-delaylib.lib wintrust-delaylib.lib uxtheme-delaylib.lib +all: dwmapi-delaylib.lib version-delaylib.lib wintrust-delaylib.lib %.def64: %.def $(AM_V_SED) "s/@.*//" $< >$@ diff --git a/.mingw/dwmapi.def b/.mingw/dwmapi.def index 393c04e0..240e17c7 100644 --- a/.mingw/dwmapi.def +++ b/.mingw/dwmapi.def @@ -1,3 +1,2 @@ EXPORTS DwmGetWindowAttribute@16 - DwmSetWindowAttribute@16 diff --git a/.mingw/uxtheme.def b/.mingw/uxtheme.def deleted file mode 100644 index 3f772ac0..00000000 --- a/.mingw/uxtheme.def +++ /dev/null @@ -1,79 +0,0 @@ -; -; Definition file of UxTheme.dll -; Automatic generated by gendef -; written by Kai Tietz 2008 -; -LIBRARY "UxTheme.dll" -EXPORTS -BeginPanningFeedback@4 -EndPanningFeedback@8 -UpdatePanningFeedback@16 -BeginBufferedAnimation@32 -BeginBufferedPaint@20 -BufferedPaintClear@8 -BufferedPaintInit@0 -BufferedPaintRenderAnimation@8 -BufferedPaintSetAlpha@12 -DrawThemeBackgroundEx@24 -BufferedPaintStopAllAnimations@4 -BufferedPaintUnInit@0 -CloseThemeData@4 -DrawThemeBackground@24 -DrawThemeEdge@32 -DrawThemeIcon@28 -DrawThemeParentBackground@12 -DrawThemeParentBackgroundEx@16 -DrawThemeText@36 -OpenThemeDataEx@12 -DrawThemeTextEx@36 -EnableThemeDialogTexture@8 -EnableTheming@4 -EndBufferedAnimation@8 -EndBufferedPaint@8 -GetBufferedPaintBits@12 -GetBufferedPaintDC@4 -GetBufferedPaintTargetDC@4 -GetBufferedPaintTargetRect@8 -GetCurrentThemeName@24 -GetThemeAppProperties@0 -GetThemeBackgroundContentRect@24 -GetThemeBackgroundExtent@24 -GetThemeBackgroundRegion@24 -GetThemeBitmap@24 -GetThemeBool@20 -GetThemeColor@20 -GetThemeDocumentationProperty@16 -GetThemeEnumValue@20 -GetThemeFilename@24 -GetThemeFont@24 -GetThemeInt@20 -GetThemeIntList@20 -GetThemeMargins@28 -GetThemeMetric@24 -GetThemePartSize@28 -GetThemePosition@20 -GetThemePropertyOrigin@20 -GetThemeRect@20 -GetThemeStream@28 -GetThemeString@24 -GetThemeSysBool@8 -GetThemeSysColor@8 -GetThemeSysColorBrush@8 -GetThemeSysFont@12 -GetThemeSysInt@12 -GetThemeSysSize@8 -GetThemeSysString@16 -GetThemeTextExtent@36 -GetThemeTextMetrics@20 -GetThemeTransitionDuration@24 -GetWindowTheme@4 -HitTestThemeBackground@40 -IsAppThemed@0 -IsCompositionActive@0 -IsThemeActive@0 -IsThemeBackgroundPartiallyTransparent@12 -IsThemeDialogTextureEnabled@4 -IsThemePartDefined@12 -OpenThemeData@8 -SetThemeAppProperties@4 -SetWindowTheme@12 \ No newline at end of file diff --git a/.vs/rufus.vcxproj b/.vs/rufus.vcxproj index 414c633f..7266623b 100644 --- a/.vs/rufus.vcxproj +++ b/.vs/rufus.vcxproj @@ -133,12 +133,12 @@ /utf-8 $(ExternalCompilerOptions) %(AdditionalOptions) - advapi32.lib;comctl32.lib;crypt32.lib;gdi32.lib;ole32.lib;dwmapi.lib;setupapi.lib;uxtheme.lib;shell32.lib;shlwapi.lib;version.lib;wintrust.lib;%(AdditionalDependencies) + advapi32.lib;comctl32.lib;crypt32.lib;gdi32.lib;ole32.lib;dwmapi.lib;setupapi.lib;shell32.lib;shlwapi.lib;version.lib;wintrust.lib;%(AdditionalDependencies) RequireAdministrator true Windows MachineX86 - advapi32.dll;comctl32.dll;crypt32.dll;gdi32.dll;ole32.dll;dwmapi.dll;setupapi.dll;uxtheme.dll;shell32.dll;shlwapi.dll;version.dll;wintrust.dll;%(DelayLoadDLLs) + advapi32.dll;comctl32.dll;crypt32.dll;gdi32.dll;ole32.dll;dwmapi.dll;setupapi.dll;shell32.dll;shlwapi.dll;version.dll;wintrust.dll;%(DelayLoadDLLs) _UNICODE;UNICODE;%(PreprocessorDefinitions) @@ -162,12 +162,12 @@ /utf-8 $(ExternalCompilerOptions) %(AdditionalOptions) - advapi32.lib;comctl32.lib;crypt32.lib;gdi32.lib;ole32.lib;dwmapi.lib;setupapi.lib;uxtheme.lib;shell32.lib;shlwapi.lib;version.lib;wintrust.lib;ole32.lib;advapi32.lib;gdi32.lib;shell32.lib;comdlg32.lib;%(AdditionalDependencies) + advapi32.lib;comctl32.lib;crypt32.lib;gdi32.lib;ole32.lib;dwmapi.lib;setupapi.lib;shell32.lib;shlwapi.lib;version.lib;wintrust.lib;ole32.lib;advapi32.lib;gdi32.lib;shell32.lib;comdlg32.lib;%(AdditionalDependencies) RequireAdministrator true Windows C:\Program Files (x86)\Windows Kits\10\Lib\10.0.15063.0\um\arm - advapi32.dll;comctl32.dll;crypt32.dll;gdi32.dll;ole32.dll;dwmapi.dll;setupapi.dll;uxtheme.dll;shell32.dll;shlwapi.dll;version.dll;wintrust.dll;ole32.dll;advapi32.dll;gdi32.dll;shell32.dll;comdlg32.dll;%(DelayLoadDLLs) + advapi32.dll;comctl32.dll;crypt32.dll;gdi32.dll;ole32.dll;dwmapi.dll;setupapi.dll;shell32.dll;shlwapi.dll;version.dll;wintrust.dll;ole32.dll;advapi32.dll;gdi32.dll;shell32.dll;comdlg32.dll;%(DelayLoadDLLs) _UNICODE;UNICODE;%(PreprocessorDefinitions) @@ -193,12 +193,12 @@ /utf-8 $(ExternalCompilerOptions) %(AdditionalOptions) - advapi32.lib;comctl32.lib;crypt32.lib;gdi32.lib;ole32.lib;dwmapi.lib;setupapi.lib;uxtheme.lib;shell32.lib;shlwapi.lib;version.lib;wintrust.lib;ole32.lib;advapi32.lib;gdi32.lib;shell32.lib;comdlg32.lib;%(AdditionalDependencies) + advapi32.lib;comctl32.lib;crypt32.lib;gdi32.lib;ole32.lib;dwmapi.lib;setupapi.lib;shell32.lib;shlwapi.lib;version.lib;wintrust.lib;ole32.lib;advapi32.lib;gdi32.lib;shell32.lib;comdlg32.lib;%(AdditionalDependencies) RequireAdministrator true Windows C:\Program Files (x86)\Windows Kits\10\Lib\10.0.16299.0\um\arm64 - advapi32.dll;comctl32.dll;crypt32.dll;gdi32.dll;ole32.dll;dwmapi.dll;setupapi.dll;uxtheme.dll;shell32.dll;shlwapi.dll;version.dll;wintrust.dll;ole32.dll;advapi32.dll;gdi32.dll;shell32.dll;comdlg32.dll;%(DelayLoadDLLs) + advapi32.dll;comctl32.dll;crypt32.dll;gdi32.dll;ole32.dll;dwmapi.dll;setupapi.dll;shell32.dll;shlwapi.dll;version.dll;wintrust.dll;ole32.dll;advapi32.dll;gdi32.dll;shell32.dll;comdlg32.dll;%(DelayLoadDLLs) _UNICODE;UNICODE;%(PreprocessorDefinitions) @@ -229,12 +229,12 @@ /utf-8 $(ExternalCompilerOptions) %(AdditionalOptions) - advapi32.lib;comctl32.lib;crypt32.lib;gdi32.lib;ole32.lib;dwmapi.lib;setupapi.lib;uxtheme.lib;shell32.lib;shlwapi.lib;version.lib;wintrust.lib;%(AdditionalDependencies) + advapi32.lib;comctl32.lib;crypt32.lib;gdi32.lib;ole32.lib;dwmapi.lib;setupapi.lib;shell32.lib;shlwapi.lib;version.lib;wintrust.lib;%(AdditionalDependencies) RequireAdministrator true Windows MachineX64 - advapi32.dll;comctl32.dll;crypt32.dll;gdi32.dll;ole32.dll;dwmapi.dll;setupapi.dll;uxtheme.dll;shell32.dll;shlwapi.dll;version.dll;wintrust.dll;%(DelayLoadDLLs) + advapi32.dll;comctl32.dll;crypt32.dll;gdi32.dll;ole32.dll;dwmapi.dll;setupapi.dll;shell32.dll;shlwapi.dll;version.dll;wintrust.dll;%(DelayLoadDLLs) _UNICODE;UNICODE;%(PreprocessorDefinitions) @@ -260,13 +260,13 @@ true - advapi32.lib;comctl32.lib;crypt32.lib;gdi32.lib;ole32.lib;dwmapi.lib;setupapi.lib;uxtheme.lib;shell32.lib;shlwapi.lib;version.lib;wintrust.lib;%(AdditionalDependencies) + advapi32.lib;comctl32.lib;crypt32.lib;gdi32.lib;ole32.lib;dwmapi.lib;setupapi.lib;shell32.lib;shlwapi.lib;version.lib;wintrust.lib;%(AdditionalDependencies) RequireAdministrator false Windows MachineX86 /BREPRO %(AdditionalOptions) - advapi32.dll;comctl32.dll;crypt32.dll;gdi32.dll;ole32.dll;dwmapi.dll;setupapi.dll;uxtheme.dll;shell32.dll;shlwapi.dll;version.dll;wintrust.dll;%(DelayLoadDLLs) + advapi32.dll;comctl32.dll;crypt32.dll;gdi32.dll;ole32.dll;dwmapi.dll;setupapi.dll;shell32.dll;shlwapi.dll;version.dll;wintrust.dll;%(DelayLoadDLLs) _UNICODE;UNICODE;%(PreprocessorDefinitions) @@ -292,13 +292,13 @@ true - advapi32.lib;comctl32.lib;crypt32.lib;gdi32.lib;ole32.lib;dwmapi.lib;setupapi.lib;uxtheme.lib;shell32.lib;shlwapi.lib;version.lib;wintrust.lib;ole32.lib;advapi32.lib;gdi32.lib;shell32.lib;comdlg32.lib;%(AdditionalDependencies) + advapi32.lib;comctl32.lib;crypt32.lib;gdi32.lib;ole32.lib;dwmapi.lib;setupapi.lib;shell32.lib;shlwapi.lib;version.lib;wintrust.lib;ole32.lib;advapi32.lib;gdi32.lib;shell32.lib;comdlg32.lib;%(AdditionalDependencies) RequireAdministrator false Windows C:\Program Files (x86)\Windows Kits\10\Lib\10.0.15063.0\um\arm /BREPRO %(AdditionalOptions) - advapi32.dll;comctl32.dll;crypt32.dll;gdi32.dll;ole32.dll;dwmapi.dll;setupapi.dll;uxtheme.dll;shell32.dll;shlwapi.dll;version.dll;wintrust.dll;ole32.dll;advapi32.dll;gdi32.dll;shell32.dll;comdlg32.dll;%(DelayLoadDLLs) + advapi32.dll;comctl32.dll;crypt32.dll;gdi32.dll;ole32.dll;dwmapi.dll;setupapi.dll;shell32.dll;shlwapi.dll;version.dll;wintrust.dll;ole32.dll;advapi32.dll;gdi32.dll;shell32.dll;comdlg32.dll;%(DelayLoadDLLs) _UNICODE;UNICODE;%(PreprocessorDefinitions) @@ -326,13 +326,13 @@ true - advapi32.lib;comctl32.lib;crypt32.lib;gdi32.lib;ole32.lib;dwmapi.lib;setupapi.lib;uxtheme.lib;shell32.lib;shlwapi.lib;version.lib;wintrust.lib;ole32.lib;advapi32.lib;gdi32.lib;shell32.lib;comdlg32.lib;%(AdditionalDependencies) + advapi32.lib;comctl32.lib;crypt32.lib;gdi32.lib;ole32.lib;dwmapi.lib;setupapi.lib;shell32.lib;shlwapi.lib;version.lib;wintrust.lib;ole32.lib;advapi32.lib;gdi32.lib;shell32.lib;comdlg32.lib;%(AdditionalDependencies) RequireAdministrator false Windows C:\Program Files (x86)\Windows Kits\10\Lib\10.0.16299.0\um\arm64 /BREPRO %(AdditionalOptions) - advapi32.dll;comctl32.dll;crypt32.dll;gdi32.dll;ole32.dll;dwmapi.dll;setupapi.dll;uxtheme.dll;shell32.dll;shlwapi.dll;version.dll;wintrust.dll;ole32.dll;advapi32.dll;gdi32.dll;shell32.dll;comdlg32.dll;%(DelayLoadDLLs) + advapi32.dll;comctl32.dll;crypt32.dll;gdi32.dll;ole32.dll;dwmapi.dll;setupapi.dll;shell32.dll;shlwapi.dll;version.dll;wintrust.dll;ole32.dll;advapi32.dll;gdi32.dll;shell32.dll;comdlg32.dll;%(DelayLoadDLLs) _UNICODE;UNICODE;%(PreprocessorDefinitions) @@ -363,13 +363,13 @@ true - advapi32.lib;comctl32.lib;crypt32.lib;gdi32.lib;ole32.lib;dwmapi.lib;setupapi.lib;uxtheme.lib;uxtheme.lib;shell32.lib;shlwapi.lib;version.lib;wintrust.lib;%(AdditionalDependencies) + advapi32.lib;comctl32.lib;crypt32.lib;gdi32.lib;ole32.lib;dwmapi.lib;setupapi.lib;shell32.lib;shlwapi.lib;version.lib;wintrust.lib;%(AdditionalDependencies) RequireAdministrator false Windows MachineX64 /BREPRO %(AdditionalOptions) - advapi32.dll;comctl32.dll;crypt32.dll;gdi32.dll;ole32.dll;dwmapi.dll;setupapi.dll;uxtheme.dll;shell32.dll;shlwapi.dll;version.dll;wintrust.dll;%(DelayLoadDLLs) + advapi32.dll;comctl32.dll;crypt32.dll;gdi32.dll;ole32.dll;dwmapi.dll;setupapi.dll;shell32.dll;shlwapi.dll;version.dll;wintrust.dll;%(DelayLoadDLLs) _UNICODE;UNICODE;%(PreprocessorDefinitions) diff --git a/src/Makefile.in b/src/Makefile.in index 6c20da30..70d31a54 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -280,7 +280,7 @@ NONVULNERABLE_LIBS = -lsetupapi -lole32 -lgdi32 -lshlwapi -lcrypt32 -lcomctl32 - # Ideally there would also be virtdisk and wininet as delaylib's below, but the MinGW folks haven't quite sorted out delay-loading # for x86_32 so as soon as you try to call APIs from these, the application will crash! # See https://github.com/pbatard/rufus/issues/1877#issuecomment-1109683039 as well as https://github.com/pbatard/rufus/issues/2272 -VULNERABLE_LIBS = -ldwmapi-delaylib -lversion-delaylib -lwintrust-delaylib -luxtheme-delaylib +VULNERABLE_LIBS = -ldwmapi-delaylib -lversion-delaylib -lwintrust-delaylib AM_V_WINDRES_0 = @echo " RC $@";$(WINDRES) AM_V_WINDRES_1 = $(WINDRES) AM_V_WINDRES_ = $(AM_V_WINDRES_$(AM_DEFAULT_VERBOSITY)) diff --git a/src/registry.h b/src/registry.h index b6d401ea..7e8312bc 100644 --- a/src/registry.h +++ b/src/registry.h @@ -26,17 +26,10 @@ #ifdef __cplusplus extern "C" { #endif - -// disable all warnings until fix theme -#ifdef __GNUC__ -#pragma GCC diagnostic ignored "-Wstrict-prototypes" -#pragma GCC diagnostic ignored "-Wunused-variable" -#endif #define REGKEY_HKCU HKEY_CURRENT_USER #define REGKEY_HKLM HKEY_LOCAL_MACHINE - /* Delete a registry key from \Software and all its values If the key has subkeys, this call will fail. */ static __inline BOOL DeleteRegistryKey(HKEY key_root, const char* key_name) diff --git a/src/rufus.c b/src/rufus.c index 4d1c6f34..d106ec71 100755 --- a/src/rufus.c +++ b/src/rufus.c @@ -59,9 +59,8 @@ #include "../res/grub2/grub2_version.h" #include #include -#include - - +#pragma comment(lib,"UxTheme.lib") +#pragma comment(lib,"DwmApi.lib") enum bootcheck_return { BOOTCHECK_PROCEED = 0, BOOTCHECK_CANCEL = -1, @@ -107,7 +106,7 @@ extern const char* old_c32_name[NB_OLD_C32]; extern const char* cert_name[3]; extern const char* FileSystemLabel[FS_MAX]; extern const char *bootmgr_efi_name, *efi_dirname, *efi_bootname[ARCH_MAX]; -static UINT_PTR uIdSubclass = 1; + /* * Globals */ @@ -155,7 +154,8 @@ RUFUS_DRIVE rufus_drive[MAX_DRIVES] = { 0 }; // This function sets the alpha channel to 255 without // affecting any of the color channels. -void MakeBitmapOpaque( HDC hdc, int x, int y, int cx, int cy) +void MakeBitmapOpaque( + HDC hdc, int x, int y, int cx, int cy) { BITMAPINFO bi = {0}; bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); @@ -164,8 +164,12 @@ void MakeBitmapOpaque( HDC hdc, int x, int y, int cx, int cy) bi.bmiHeader.biPlanes = 1; bi.bmiHeader.biBitCount = 32; bi.bmiHeader.biCompression = BI_RGB; + RGBQUAD bitmapBits = { 0x00, 0x00, 0x00, 0xFF }; - StretchDIBits(hdc, x, y, cx, cy, 0, 0, 1, 1, &bitmapBits, &bi,DIB_RGB_COLORS, SRCPAINT); + + StretchDIBits(hdc, x, y, cx, cy, + 0, 0, 1, 1, &bitmapBits, &bi, + DIB_RGB_COLORS, SRCPAINT); } // TODO: Remember to update copyright year in stdlg's AboutCallback() WM_INITDIALOG, @@ -959,9 +963,10 @@ out: * DarkMode CheckBox Subclass Proc */ -static LRESULT CALLBACK ButtonSubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam,LPARAM lParam, UINT_PTR idSubclass, DWORD_PTR dwRefData) +static LRESULT CALLBACK ButtonSubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam, + LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData) { - if (!IsAppsUseDarkMode()) + if (!IsAppsUseDarkMode) { return DefSubclassProc(hWnd, uMsg, wParam, lParam); } @@ -988,15 +993,15 @@ static LRESULT CALLBACK ButtonSubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam,L rc1.left += siz.cx + 2; FillRect(hDc, &rc1, CreateSolidBrush(ColorControlDark)); rc1.top += GetSystemMetrics(SM_CXPADDEDBORDER); - WCHAR szCaption[60]; - GetWindowText(hWnd, szCaption, ARRAYSIZE(szCaption)); + LPCWSTR* staticText[99] = {0}; + GetWindowText(hWnd, staticText, ARRAYSIZE(staticText)); DTTOPTS opts; opts.dwSize = sizeof(DTTOPTS); opts.dwFlags = DTT_TEXTCOLOR; opts.crText = RGB(255, 255, 255); HFONT font = (HFONT)SendMessage(hWnd, WM_GETFONT, 0, 0); SelectObject(hDc, font); - DrawThemeTextEx(btnTheme, hDc, 3, 0, szCaption, -1, DT_SINGLELINE | DT_LEFT, &rc1, &opts); + DrawThemeTextEx(btnTheme, hDc, 3, 0, &staticText, -1, DT_SINGLELINE | DT_LEFT, &rc1, &opts); ReleaseDC(hWnd, hDc); return true; } @@ -1008,10 +1013,10 @@ static LRESULT CALLBACK ButtonSubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam,L */ static BOOL CALLBACK ThemeCallback(HWND hWnd, LPARAM lParam) { - WCHAR str[20] = {0}; - GetClassName(hWnd, str, 20); + const char* str[255] = {0}; + GetClassName(hWnd, &str, 255); bool isDarkmode = IsAppsUseDarkMode(); - if (_wcsicmp(str, L"Button") == 0) + if (strcmp(str, L"Button") == 0) { LONG_PTR style = GetWindowLongPtr(hWnd, GWL_STYLE); if ((style & BS_AUTOCHECKBOX) == BS_AUTOCHECKBOX) @@ -1028,20 +1033,20 @@ static BOOL CALLBACK ThemeCallback(HWND hWnd, LPARAM lParam) else SetWindowTheme(hWnd, isDarkmode ? L"DarkMode_Explorer" : L"Explorer", NULL); } - else if (_wcsicmp(str, L"ComboBox") == 0) + else if (strcmp(str, L"ComboBox") == 0) { SetWindowTheme(hWnd, isDarkmode ? L"DarkMode_CFD" : L"Explorer", NULL); } - else if (_wcsicmp(str, L"ToolbarWindow32") == 0) + else if (strcmp(str, L"ToolBar") == 0) { wchar_t toolbarText[50]; wchar_t multiToolbarText[50] ; utf8_to_wchar_no_alloc(lmprintf(MSG_315), multiToolbarText, ARRAYSIZE(multiToolbarText)); GetWindowText(hWnd, &toolbarText, 16); - if (_wcsicmp(toolbarText, multiToolbarText) != 0) + if (strcmp(toolbarText, multiToolbarText) != 0) SetWindowTheme(hWnd, isDarkmode ? L"DarkMode" : L"Explorer", NULL); } - else if (_wcsicmp(str, L"EDIT") == 0) + else if (strcmp(str, L"EDIT") == 0) { LONG_PTR style = GetWindowLongPtr(hWnd, GWL_STYLE); if (((style & WS_VSCROLL) == WS_VSCROLL) || ((style & WS_HSCROLL) == WS_HSCROLL)) @@ -1060,9 +1065,11 @@ static BOOL CALLBACK ThemeCallback(HWND hWnd, LPARAM lParam) * DarkMod Dialog Subclass Proc */ -static LRESULT CALLBACK DlgSubclassProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam, UINT_PTR idSubclass, DWORD_PTR dwRefData) +static LRESULT CALLBACK DlgSubclassProc(HWND hDlg, UINT message, WPARAM wParam, + LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData) { - + RECT rcDlg; + GetClientRect(hDlg, &rcDlg); HDC dc; switch (message) { @@ -1081,17 +1088,16 @@ static LRESULT CALLBACK DlgSubclassProc(HWND hDlg, UINT message, WPARAM wParam, int borderWidth = (rcWinWidth - rcrcClientWidth) / 2; int captionHight = rcWinHieght - rcrcClientHieght - borderWidth; OffsetRect(&rcWin, -rcWin.left, -rcWin.top); - OffsetRect(&rcClient, -rcWin.left, -rcWin.top); - HRGN copy =CreateRectRgn(0, 0, 0, 0); - HRGN updateRgn = wParam != 1 ? copy : CreateRectRgnIndirect(&rcWin); + OffsetRect(&rcClient, borderWidth, captionHight); + HRGN updateRgn = wParam != 1 ?(HRGN)wParam : CreateRectRgnIndirect(&rcWin); HRGN clipRgn = CreateRectRgn(0, 0, 0, 0); HRGN ncRgn = CreateRectRgn(0, 0, 0, 0); - CombineRgn(copy, copy, (HRGN)wParam, RGN_COPY); + if (wParam == 1) clipRgn = CreateRectRgnIndirect(&rcClient); else GetClipRgn(windowDC, clipRgn); - CombineRgn(ncRgn, updateRgn, clipRgn, RGN_OR); + CombineRgn(ncRgn, updateRgn, clipRgn, RGN_DIFF); SelectClipRgn(windowDC, ncRgn); FillRect(windowDC, &rcWin, CreateSolidBrush(RGB(63, 63, 63))); HRGN hRgn= CreateRectRgnIndirect(&rcWin); @@ -1171,6 +1177,8 @@ static LRESULT CALLBACK DlgSubclassProc(HWND hDlg, UINT message, WPARAM wParam, return (INT_PTR)CreateSolidBrush(ColorControlDark); case WM_CTLCOLORSTATIC: dc = GetDC((HWND)lParam); + RECT rcDlg; + GetClientRect((HWND)lParam, &rcDlg); safe_release_dc((HWND)lParam, dc); if ((HWND)lParam == GetDlgItem(hDlg, IDC_LABEL)) { diff --git a/src/stdlg.c b/src/stdlg.c index 5d9afca8..532f81c5 100644 --- a/src/stdlg.c +++ b/src/stdlg.c @@ -44,7 +44,6 @@ #include "settings.h" #include "license.h" #include -#include /* Globals */ extern BOOL is_x86_64, appstore_version; @@ -62,7 +61,6 @@ static const char* notification_dont_display_setting; static WNDPROC update_original_proc = NULL; static HWINEVENTHOOK ap_weh = NULL; static char title_str[2][128], button_str[128]; -static UINT_PTR uIdSubclass = 1; HWND hFidoDlg = NULL; static int update_settings_reposition_ids[] = { @@ -78,8 +76,6 @@ static int update_settings_reposition_ids[] = { IDCANCEL, }; - - /* * https://blogs.msdn.microsoft.com/oldnewthing/20040802-00/?p=38283/ */ @@ -92,9 +88,10 @@ void SetDialogFocus(HWND hDlg, HWND hCtrl) * DarkMode CheckBox Subclass Proc */ -static LRESULT CALLBACK ButtonSubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR idSubclass, DWORD_PTR dwRefData) +static LRESULT CALLBACK ButtonSubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam, + LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData) { - if (!IsAppsUseDarkMode()) + if (!IsAppsUseDarkMode) { return DefSubclassProc(hWnd, uMsg, wParam, lParam); } @@ -121,15 +118,15 @@ static LRESULT CALLBACK ButtonSubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam, rc1.left += siz.cx + 2; FillRect(hDc, &rc1, CreateSolidBrush(ColorControlDark)); rc1.top += GetSystemMetrics(SM_CXPADDEDBORDER); - WCHAR szCaption[60]; - GetWindowText(hWnd, szCaption, ARRAYSIZE(szCaption)); + LPCWSTR* staticText[99] = {0}; + GetWindowText(hWnd, staticText, ARRAYSIZE(staticText)); DTTOPTS opts; opts.dwSize = sizeof(DTTOPTS); opts.dwFlags = DTT_TEXTCOLOR; opts.crText = RGB(255, 255, 255); HFONT font = (HFONT)SendMessage(hWnd, WM_GETFONT, 0, 0); SelectObject(hDc, font); - DrawThemeTextEx(btnTheme, hDc, 3, 0, szCaption, -1, DT_SINGLELINE | DT_LEFT, &rc1, &opts); + DrawThemeTextEx(btnTheme, hDc, 3, 0, &staticText, -1, DT_SINGLELINE | DT_LEFT, &rc1, &opts); ReleaseDC(hWnd, hDc); return TRUE; } @@ -143,11 +140,11 @@ static LRESULT CALLBACK ButtonSubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam, static BOOL CALLBACK ThemeCallback(HWND hWnd, LPARAM lParam) { - WCHAR str[30] = { 0 }; - GetClassName(hWnd, str, ARRAYSIZE(str)); + char* str[255]; + GetClassName(hWnd, &str, 255); BOOL isDarkMode = IsAppsUseDarkMode(); - if (_wcsicmp(str, L"Button") == 0) + if (strcmp(str, L"Button") == 0) { LONG_PTR style = GetWindowLongPtr(hWnd, GWL_STYLE); if ((style & BS_AUTOCHECKBOX) == BS_AUTOCHECKBOX) @@ -164,18 +161,18 @@ static BOOL CALLBACK ThemeCallback(HWND hWnd, LPARAM lParam) else SetWindowTheme(hWnd, isDarkMode ? L"DarkMode_Explorer" : L"Explorer", NULL); } - else if (_wcsicmp(str, L"ComboBox") == 0) + else if (strcmp(str, L"ComboBox") == 0) { SetWindowTheme(hWnd, isDarkMode ? L"DarkMode_CFD" : L"Explorer", NULL); } - else if (_wcsicmp(str, L"ToolBar") == 0) + else if (strcmp(str, L"ToolBar") == 0) { - WCHAR title[30] = {0}; - GetWindowText(hWnd, title, ARRAYSIZE(title)); - if (_wcsicmp(title, L"Multiple buttons") != 0) + char* title[16]; + GetWindowText(hWnd, &title, 16); + if (strcmp(title, L"Multiple buttons") != 0) SetWindowTheme(hWnd, isDarkMode ? L"DarkMode" : L"Explorer", NULL); } - else if (_wcsicmp(str, L"EDIT") == 0) + else if (strcmp(str, L"EDIT") == 0) { LONG_PTR style = GetWindowLongPtr(hWnd, GWL_STYLE); if(((style & WS_VSCROLL) == WS_VSCROLL) || ((style & WS_HSCROLL) == WS_HSCROLL)) @@ -185,7 +182,7 @@ static BOOL CALLBACK ThemeCallback(HWND hWnd, LPARAM lParam) } - else if (_wcsicmp(str, L"RichEdit20W") == 0) + else if (strcmp(str, L"RichEdit20W") == 0) { SendMessage(hWnd, EM_SETBKGNDCOLOR, 0, isDarkMode ? (LPARAM)ColorControlDark : (LPARAM)GetSysColor(COLOR_BTNFACE)); CHARFORMAT cf; @@ -207,7 +204,8 @@ static BOOL CALLBACK ThemeCallback(HWND hWnd, LPARAM lParam) * DarkMod Dialog Subclass Proc */ -static LRESULT CALLBACK DlgSubclassProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam, UINT_PTR idSubclass, DWORD_PTR dwRefData) +static LRESULT CALLBACK DlgSubclassProc(HWND hDlg, UINT message, WPARAM wParam, + LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData) { if (!IsAppsUseDarkMode()) { @@ -215,94 +213,9 @@ static LRESULT CALLBACK DlgSubclassProc(HWND hDlg, UINT message, WPARAM wParam, } switch (message) { - case WM_NCPAINT: - { - LRESULT result = DefSubclassProc(hDlg, message, wParam, lParam); - HDC windowDC = GetWindowDC(hDlg); - RECT rcWin, rcClient; - GetWindowRect(hDlg, &rcWin); - GetClientRect(hDlg, &rcClient); - MapWindowPoints(hDlg, NULL, (LPPOINT)&rcWin, 2); - int rcWinWidth = rcWin.right - rcWin.left; - int rcWinHieght = rcWin.bottom - rcWin.top; - int rcrcClientWidth = rcClient.right - rcClient.left; - int rcrcClientHieght = rcClient.bottom - rcClient.top; - int borderWidth = (rcWinWidth - rcrcClientWidth) / 2; - int captionHight = rcWinHieght - rcrcClientHieght - borderWidth; - OffsetRect(&rcWin, -rcWin.left, -rcWin.top); - OffsetRect(&rcClient, -rcWin.left, -rcWin.top); - HRGN copy = CreateRectRgn(0, 0, 0, 0); - HRGN updateRgn = wParam != 1 ? copy : CreateRectRgnIndirect(&rcWin); - HRGN clipRgn = CreateRectRgn(0, 0, 0, 0); - HRGN ncRgn = CreateRectRgn(0, 0, 0, 0); - CombineRgn(copy, copy, (HRGN)wParam, RGN_COPY); - if (wParam == 1) - clipRgn = CreateRectRgnIndirect(&rcClient); - else - GetClipRgn(windowDC, clipRgn); - CombineRgn(ncRgn, updateRgn, clipRgn, RGN_OR); - SelectClipRgn(windowDC, ncRgn); - FillRect(windowDC, &rcWin, CreateSolidBrush(RGB(63, 63, 63))); - HRGN hRgn = CreateRectRgnIndirect(&rcWin); - SelectClipRgn(windowDC, hRgn); - MakeBitmapOpaque(windowDC, 0, 0, rcWinWidth, rcWinHieght); - safe_release_dc(hDlg, windowDC); - return result; - } - case WM_NCCALCSIZE: - { - //TODO: get real caption Size - - if (wParam) - { - NCCALCSIZE_PARAMS* ncParma = (NCCALCSIZE_PARAMS*)(lParam); - ncParma->rgrc[0].left += 1;//pr++; - ncParma->rgrc[0].top += 31; - ncParma->rgrc[0].right -= 1; - ncParma->rgrc[0].bottom -= 1; - return 0; - } - else - { - RECT* rect = (RECT*)lParam; - rect->top += 31; - rect->left += 1; - rect->right -= 1; - rect->bottom -= 1; - return 0; - } - } - case WM_SHOWWINDOW: - { - if (wParam) - { - EnumChildWindows(hDlg, ThemeCallback, lParam); - BOOL allowncpaint = TRUE; - COLORREF caption = RGB(0x0, 0x0, 0x0); - DwmSetWindowAttribute(hDlg, DWMWA_CAPTION_COLOR, &caption, sizeof caption); - DwmSetWindowAttribute(hDlg, DWMWA_BORDER_COLOR, &caption, sizeof caption); - DwmSetWindowAttribute(hDlg, DWMWA_ALLOW_NCPAINT, &allowncpaint, sizeof(int)); - RECT rcDlg; - GetWindowRect(hDlg, &rcDlg); - SetWindowPos(hDlg, 0, 0, 0, rcDlg.right - rcDlg.left, rcDlg.bottom - rcDlg.top, SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE); - - if (hLog) - { - RECT rcLog; - GetWindowRect(hLog, &rcLog); - GetClientRect(hDlg, &rcDlg); - rcLog.left = rcDlg.left + 1; - rcLog.right = rcDlg.right - 1; - SetWindowPos(hLog, NULL, 0, 0, rcLog.right - rcLog.left, rcLog.bottom - rcLog.top, SWP_NOMOVE | SWP_NOZORDER); - } - RedrawWindow(hDlg, NULL, NULL, RDW_ALLCHILDREN | RDW_UPDATENOW | RDW_INVALIDATE | RDW_FRAME | RDW_ERASENOW); - } - - return DefSubclassProc(hDlg, message, wParam, lParam); - - } - + EnumChildWindows(hDlg, ThemeCallback, lParam); + return DefWindowProc(hDlg, message, wParam, lParam); case WM_CTLCOLORLISTBOX: SetBkColor((HDC)wParam, RGB(25, 25, 25)); SetTextColor((HDC)wParam, RGB(255, 255, 255)); @@ -315,7 +228,6 @@ static LRESULT CALLBACK DlgSubclassProc(HWND hDlg, UINT message, WPARAM wParam, return (INT_PTR)CreateSolidBrush(RGB(25, 25, 25)); } - case WM_CTLCOLORBTN: case WM_CTLCOLORDLG: return (INT_PTR)CreateSolidBrush(ColorControlDark); diff --git a/src/ui.h b/src/ui.h index 0e2189be..c0bb1a2c 100644 --- a/src/ui.h +++ b/src/ui.h @@ -116,4 +116,4 @@ extern void ShowLanguageMenu(RECT rcExclude); extern void SetPassesTooltip(void); extern void SetBootTypeDropdownWidth(void); extern void OnPaint(HDC hdc); -extern void MakeBitmapOpaque(HDC hdc, int x, int y, int cx, int cy); +static UINT_PTR uIdSubclass = 1; diff --git a/src/ui_data.h b/src/ui_data.h index 03dde1d7..be33e8c1 100644 --- a/src/ui_data.h +++ b/src/ui_data.h @@ -20,10 +20,6 @@ #include #include "resource.h" - // disable all warnings about unused variable -#ifdef __GNUC__ -#pragma GCC diagnostic ignored "-Wunused-variable" -#endif #pragma once // GUIDs needed to set a control's accessibility props