From 7cf648351ef87560c2bcb7d87c9e291ad2bfc7ab Mon Sep 17 00:00:00 2001 From: rkotten Date: Wed, 22 Mar 2023 15:43:57 +0100 Subject: [PATCH] +rfc: fallback on LoadIconWithScaleDown() failed --- language/common_res.h | 21 ++--- lexilla/Lexilla.vcxproj | 3 +- scintilla/Scintilla.vcxproj | 3 +- src/DarkMode/user32-stub/user32-stub.vcxproj | 2 +- .../uxtheme-stub/uxtheme-stub.vcxproj | 2 +- src/Notepad3.c | 82 ++++++++++--------- src/Notepad3.vcxproj | 5 +- 7 files changed, 64 insertions(+), 54 deletions(-) diff --git a/language/common_res.h b/language/common_res.h index 8f3302983..b54b60bdd 100644 --- a/language/common_res.h +++ b/language/common_res.h @@ -65,6 +65,17 @@ // ========================================== +#define IDR_MAINWND 1000 +#define IDR_MAINWNDTB 1001 +#define IDR_MAINWNDTBHOT 1002 +#define IDR_MAINWNDTBDIS 1003 +#define IDR_MAINWNDTB2 1004 +#define IDR_MAINWNDTB2HOT 1005 +#define IDR_MAINWNDTB2DIS 1006 +#define IDR_STD_DARKMODE_THEME 1050 + +// ========================================== + #ifndef IDC_STATIC #define IDC_STATIC (-1) #endif @@ -259,16 +270,6 @@ #define IDS_MUI_SB_RECODING_DOC 15505 #define IDS_MUI_SB_LEXER_STYLING 15506 -#define IDR_MAINWND 16000 -#define IDR_MAINWNDTB 16001 -#define IDR_MAINWNDTBHOT 16002 -#define IDR_MAINWNDTBDIS 16003 -#define IDR_MAINWNDTB2 16004 -#define IDR_MAINWNDTB2HOT 16005 -#define IDR_MAINWNDTB2DIS 16006 - -#define IDR_STD_DARKMODE_THEME 16050 - #define IDI_MUI_RUN 16100 #define IDI_MUI_STYLES 16101 diff --git a/lexilla/Lexilla.vcxproj b/lexilla/Lexilla.vcxproj index ce4d50678..67be12d06 100644 --- a/lexilla/Lexilla.vcxproj +++ b/lexilla/Lexilla.vcxproj @@ -252,7 +252,7 @@ MultiThreadedDebug false - + false false false true @@ -369,6 +369,7 @@ stdc17 ProgramDatabase /utf-8 %(AdditionalOptions) + false Console diff --git a/scintilla/Scintilla.vcxproj b/scintilla/Scintilla.vcxproj index 16da66d66..5056d1196 100644 --- a/scintilla/Scintilla.vcxproj +++ b/scintilla/Scintilla.vcxproj @@ -149,7 +149,7 @@ MultiThreadedDebug Level4 false - + false true @@ -189,6 +189,7 @@ true stdc17 /utf-8 %(AdditionalOptions) + false MachineX64 diff --git a/src/DarkMode/user32-stub/user32-stub.vcxproj b/src/DarkMode/user32-stub/user32-stub.vcxproj index d442e155e..c6819d452 100644 --- a/src/DarkMode/user32-stub/user32-stub.vcxproj +++ b/src/DarkMode/user32-stub/user32-stub.vcxproj @@ -61,8 +61,8 @@ Win32Proj {1f757558-0e57-4de5-82d6-a14e9d81f05f} user32stub - 10.0 user32-stub + diff --git a/src/DarkMode/uxtheme-stub/uxtheme-stub.vcxproj b/src/DarkMode/uxtheme-stub/uxtheme-stub.vcxproj index 9931596c5..55043dec0 100644 --- a/src/DarkMode/uxtheme-stub/uxtheme-stub.vcxproj +++ b/src/DarkMode/uxtheme-stub/uxtheme-stub.vcxproj @@ -61,7 +61,7 @@ Win32Proj {0873b090-7ffd-4abd-9b42-619a06c5041f} uxthemestub - 10.0 + uxtheme-stub diff --git a/src/Notepad3.c b/src/Notepad3.c index f056c2086..31f12b08b 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -91,17 +91,18 @@ CONSTANTS_T const Constants = { }; -FLAGS_T Flags; -FLAGS_T DefaultFlags; +FLAGS_T Flags = { 0 }; +FLAGS_T DefaultFlags = { 0 }; -PATHS_T Paths; -GLOBALS_T Globals; -SETTINGS_T Settings; -SETTINGS_T Defaults; -SETTINGS2_T Settings2; +GLOBALS_T Globals = { 0 }; +SETTINGS_T Settings = { 0 }; +SETTINGS_T Defaults = { 0 }; +SETTINGS2_T Settings2 = { 0 }; -FOCUSEDVIEW_T FocusedView; -FILEWATCHING_T FileWatching; +PATHS_T Paths = { 0 }; + +FOCUSEDVIEW_T FocusedView = { 0 }; +FILEWATCHING_T FileWatching = { 0 }; // set by InitScintillaHandle() HWND g_hwndEditWindow = NULL; @@ -113,8 +114,8 @@ WININFO g_DefWinInfo = INIT_WININFO; COLORREF g_colorCustom[16] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; -prefix_t g_mxSBPrefix[STATUS_SECTOR_COUNT]; -prefix_t g_mxSBPostfix[STATUS_SECTOR_COUNT]; +prefix_t g_mxSBPrefix[STATUS_SECTOR_COUNT] = { L'\0' }; +prefix_t g_mxSBPostfix[STATUS_SECTOR_COUNT] = { L'\0' }; int g_flagMatchText = 0; bool g_iStatusbarVisible[STATUS_SECTOR_COUNT] = SBS_INIT_ZERO; @@ -125,7 +126,7 @@ HPATHL g_tchToolbarBitmap = NULL; HPATHL g_tchToolbarBitmapHot = NULL; HPATHL g_tchToolbarBitmapDisabled = NULL; -WCHAR Default_PreferredLanguageLocaleName[LOCALE_NAME_MAX_LENGTH + 1]; +WCHAR Default_PreferredLanguageLocaleName[LOCALE_NAME_MAX_LENGTH + 1] = { L'\0' }; // ------------------------------------ @@ -159,14 +160,14 @@ static bool s_bLastCopyFromMe = false; static bool s_bInMultiEditMode = false; static bool s_bCallTipEscDisabled = false; -static int s_iInitialLine; -static int s_iInitialColumn; -static int s_iInitialLexer; +static int s_iInitialLine = 0; +static int s_iInitialColumn = 0; +static int s_iInitialLexer = 0; -static int s_cyReBar; -static int s_cyReBarFrame; -static int s_cxEditFrame; -static int s_cyEditFrame; +static int s_cyReBar = 0; +static int s_cyReBarFrame = 0; +static int s_cxEditFrame = 0; +static int s_cyEditFrame = 0; static bool s_bUndoRedoScroll = false; // for tiny expression calculation @@ -712,15 +713,6 @@ static void _UpdateTitlebarDelayed(const HWND hwnd); static void _InitGlobals() { - ZeroMemory(&Paths, sizeof(PATHS_T)); - ZeroMemory(&Globals, sizeof(GLOBALS_T)); - ZeroMemory(&Defaults, sizeof(SETTINGS_T)); - ZeroMemory(&Settings, sizeof(SETTINGS_T)); - ZeroMemory(&Settings2, sizeof(SETTINGS2_T)); - ZeroMemory(&Flags, sizeof(FLAGS_T)); - - ZeroMemory(&(Globals.fvCurFile), sizeof(FILEVARS)); - Globals.hLngResContainer = NULL; Globals.hDlgIcon256 = NULL; @@ -1180,33 +1172,49 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, int const cxs = GetSystemMetrics(SM_CXSMICON) << 1; int const cys = GetSystemMetrics(SM_CYSMICON) << 1; - //UINT const fuLoad = LR_DEFAULTCOLOR | LR_SHARED; + UINT const fuLoad = LR_DEFAULTCOLOR | LR_SHARED; if (!Globals.hDlgIcon256) { - LoadIconWithScaleDown(hInstance, MAKEINTRESOURCE(IDR_MAINWND), 256, 256, &(Globals.hDlgIcon256)); + if (FAILED(LoadIconWithScaleDown(hInstance, MAKEINTRESOURCE(IDR_MAINWND), 256, 256, &(Globals.hDlgIcon256)))) { + Globals.hDlgIcon256 = LoadImage(hInstance, MAKEINTRESOURCE(IDR_MAINWND), IMAGE_ICON, 256, 256, fuLoad); + } } if (!Globals.hDlgIcon128) { - LoadIconWithScaleDown(hInstance, MAKEINTRESOURCE(IDR_MAINWND), 128, 128, &(Globals.hDlgIcon128)); + if (FAILED(LoadIconWithScaleDown(hInstance, MAKEINTRESOURCE(IDR_MAINWND), 128, 128, &(Globals.hDlgIcon128)))) { + Globals.hDlgIcon128 = LoadImage(hInstance, MAKEINTRESOURCE(IDR_MAINWND), IMAGE_ICON, 128, 128, fuLoad); + } } if (!Globals.hDlgIconBig) { - LoadIconWithScaleDown(hInstance, MAKEINTRESOURCE(IDR_MAINWND), cxb, cyb, &(Globals.hDlgIconBig)); + if (FAILED(LoadIconWithScaleDown(hInstance, MAKEINTRESOURCE(IDR_MAINWND), cxb, cyb, &(Globals.hDlgIconBig)))) { + Globals.hDlgIconBig = LoadImage(hInstance, MAKEINTRESOURCE(IDR_MAINWND), IMAGE_ICON, cxb, cyb, fuLoad); + } } if (!Globals.hDlgIconSmall) { - LoadIconWithScaleDown(hInstance, MAKEINTRESOURCE(IDR_MAINWND), cxs, cys, &(Globals.hDlgIconSmall)); + if (FAILED(LoadIconWithScaleDown(hInstance, MAKEINTRESOURCE(IDR_MAINWND), cxs, cys, &(Globals.hDlgIconSmall)))) { + Globals.hDlgIconSmall = LoadImage(hInstance, MAKEINTRESOURCE(IDR_MAINWND), IMAGE_ICON, cxs, cys, fuLoad); + } } if (!Globals.hDlgIconPrefs256) { - LoadIconWithScaleDown(hInstance, MAKEINTRESOURCE(IDI_MUI_STYLES), 256, 256, &(Globals.hDlgIconPrefs256)); + if (FAILED(LoadIconWithScaleDown(hInstance, MAKEINTRESOURCE(IDI_MUI_STYLES), 256, 256, &(Globals.hDlgIconPrefs256)))) { + Globals.hDlgIconPrefs256 = LoadImage(hInstance, MAKEINTRESOURCE(IDI_MUI_STYLES), IMAGE_ICON, 256, 256, fuLoad); + } } if (!Globals.hDlgIconPrefs128) { - LoadIconWithScaleDown(hInstance, MAKEINTRESOURCE(IDI_MUI_STYLES), 128, 128, &(Globals.hDlgIconPrefs128)); + if (FAILED(LoadIconWithScaleDown(hInstance, MAKEINTRESOURCE(IDI_MUI_STYLES), 128, 128, &(Globals.hDlgIconPrefs128)))) { + Globals.hDlgIconPrefs128 = LoadImage(hInstance, MAKEINTRESOURCE(IDI_MUI_STYLES), IMAGE_ICON, 128, 128, fuLoad); + } } if (!Globals.hDlgIconPrefs64) { - LoadIconWithScaleDown(hInstance, MAKEINTRESOURCE(IDI_MUI_STYLES), 64, 64, &(Globals.hDlgIconPrefs64)); + if (FAILED(LoadIconWithScaleDown(hInstance, MAKEINTRESOURCE(IDI_MUI_STYLES), 64, 64, &(Globals.hDlgIconPrefs64)))) { + Globals.hDlgIconPrefs64 = LoadImage(hInstance, MAKEINTRESOURCE(IDI_MUI_STYLES), IMAGE_ICON, 64, 64, fuLoad); + } } if (!Globals.hIconMsgUser) { - LoadIconWithScaleDown(hInstance, MAKEINTRESOURCE(IDR_MAINWND), cxb, cyb, &(Globals.hIconMsgUser)); + if (FAILED(LoadIconWithScaleDown(hInstance, MAKEINTRESOURCE(IDR_MAINWND), cxb, cyb, &(Globals.hIconMsgUser)))) { + Globals.hIconMsgUser = LoadImage(hInstance, MAKEINTRESOURCE(IDR_MAINWND), IMAGE_ICON, cxb, cyb, fuLoad); + } } if (!Globals.hIconMsgInfo) { LoadIconWithScaleDown(NULL, IDI_INFORMATION, cxb, cyb, &(Globals.hIconMsgInfo)); diff --git a/src/Notepad3.vcxproj b/src/Notepad3.vcxproj index 03271047f..5a8c96629 100644 --- a/src/Notepad3.vcxproj +++ b/src/Notepad3.vcxproj @@ -181,7 +181,7 @@ false /Zc:threadSafeInit /utf-8 %(AdditionalOptions) Sync - + false false true stdc17 @@ -254,8 +254,7 @@ /Zc:threadSafeInit /utf-8 %(AdditionalOptions) Sync - - + false false true stdc17