From 1b71079b135fb25bcef1d7dddd89e8e4ee34b86e Mon Sep 17 00:00:00 2001 From: Rainer Kottenhoff Date: Wed, 9 Aug 2017 10:51:43 +0200 Subject: [PATCH] - fix: nullptr access while pressing "favorites" toolbar button on 'virgin' NP3 - reintroduce HighDPI toolbar: .ini-File settings: section [Toolbar Images] + (new) HighDpiToolBar= val -1 (or not set at all) => depending on screen resolution: higher than Full-HD (1920x1080) -> select internal HighDPI-Toolbar val 0: use internal low resolution Toolbar (old behaviour) val 1: use internal HighDPI-Toolbar - (old) BitmapDefault= overrides HighDpiToolBar setting and uses (if valid) --- distrib/Notepad3.ini | Bin 1022 -> 1130 bytes minipath/src/minipath.c | 22 +++++++-------- src/Dlapi.c | 5 ++-- src/Notepad3.c | 21 +++++++++++---- src/Notepad3.rc | 52 +++++++++++++++++++----------------- src/Notepad3_VS2017.vcxproj | 1 + src/resource.h | 7 ++--- 7 files changed, 62 insertions(+), 46 deletions(-) diff --git a/distrib/Notepad3.ini b/distrib/Notepad3.ini index 41f9603bf5aef0f042c28004bdb492fa83a76d3c..3451f5204ea054ffacf41c27e45b4e7e6e469d15 100644 GIT binary patch delta 116 zcmeyz{)%J6Kjs`>1}=tZh7g8)Ak1M%Vn}2tVo+f4WXJ`w(iu`2iWy=VKx#Y~GJ*UI q1{a0`APc7639R0h!2qnr2`Ezn)>!~lm&%X^lr06CTEbupmInZk1Qm_| delta 7 OcmaFG@sEAOKV|?Az5}TM diff --git a/minipath/src/minipath.c b/minipath/src/minipath.c index caa345a3b..2453f9020 100644 --- a/minipath/src/minipath.c +++ b/minipath/src/minipath.c @@ -2774,13 +2774,21 @@ void LoadSettings() cxCopyMoveDlg = IniSectionGetInt(pIniSection,L"CopyMoveDlgSizeX",0); cxCopyMoveDlg = max(cxCopyMoveDlg,0); + int ResX = GetSystemMetrics(SM_CXSCREEN); + int ResY = GetSystemMetrics(SM_CYSCREEN); + + LoadIniSection(L"Toolbar Images", pIniSection, cbIniSection); + IniSectionGetString(pIniSection, L"BitmapDefault", L"", + tchToolbarBitmap, COUNTOF(tchToolbarBitmap)); + IniSectionGetString(pIniSection, L"BitmapHot", L"", + tchToolbarBitmapHot, COUNTOF(tchToolbarBitmap)); + IniSectionGetString(pIniSection, L"BitmapDisabled", L"", + tchToolbarBitmapDisabled, COUNTOF(tchToolbarBitmap)); + if (!flagPosParam) { // ignore window position if /p was specified WCHAR tchPosX[32], tchPosY[32], tchSizeX[32], tchSizeY[32]; - int ResX = GetSystemMetrics(SM_CXSCREEN); - int ResY = GetSystemMetrics(SM_CYSCREEN); - wsprintf(tchPosX,L"%ix%i PosX",ResX,ResY); wsprintf(tchPosY,L"%ix%i PosY",ResX,ResY); wsprintf(tchSizeX,L"%ix%i SizeX",ResX,ResY); @@ -2794,14 +2802,6 @@ void LoadSettings() wi.cy = IniSectionGetInt(pIniSection,tchSizeY,CW_USEDEFAULT); } - LoadIniSection(L"Toolbar Images",pIniSection,cbIniSection); - IniSectionGetString(pIniSection,L"BitmapDefault",L"", - tchToolbarBitmap,COUNTOF(tchToolbarBitmap)); - IniSectionGetString(pIniSection,L"BitmapHot",L"", - tchToolbarBitmapHot,COUNTOF(tchToolbarBitmap)); - IniSectionGetString(pIniSection,L"BitmapDisabled",L"", - tchToolbarBitmapDisabled,COUNTOF(tchToolbarBitmap)); - LocalFree(pIniSection); // Initialize custom colors for ChooseColor() diff --git a/src/Dlapi.c b/src/Dlapi.c index dbd784c8a..62dbc4d94 100644 --- a/src/Dlapi.c +++ b/src/Dlapi.c @@ -955,8 +955,8 @@ BOOL DirList_SelectItem(HWND hwnd,LPCWSTR lpszDisplayName,LPCWSTR lpszFullPath) void DirList_CreateFilter(PDL_FILTER pdlf,LPCWSTR lpszFileSpec, BOOL bExcludeFilter) { - - WCHAR *p; + if (!lpszFileSpec) + return; ZeroMemory(pdlf,sizeof(DL_FILTER)); lstrcpyn(pdlf->tFilterBuf,lpszFileSpec,(DL_FILTER_BUFSIZE-1)); @@ -968,6 +968,7 @@ void DirList_CreateFilter(PDL_FILTER pdlf,LPCWSTR lpszFileSpec, pdlf->nCount = 1; pdlf->pFilter[0] = &pdlf->tFilterBuf[0]; // Zeile zum Ausprobieren + WCHAR* p; while (p = StrChr(pdlf->pFilter[pdlf->nCount-1],L';')) { *p = L'\0'; // Replace L';' by L'\0' diff --git a/src/Notepad3.c b/src/Notepad3.c index 0415c9196..b5ce66dfc 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -172,6 +172,7 @@ BOOL bShowToolbar; BOOL bShowStatusbar; int iSciDirectWriteTech; int iSciFontQuality; +int iHighDpiToolBar; const int DirectWriteTechnology[] = { SC_TECHNOLOGY_DEFAULT @@ -1813,11 +1814,13 @@ void CreateBars(HWND hwnd,HINSTANCE hInstance) lstrcpy(szTmp,tchToolbarBitmap); hbmp = LoadImage(NULL,szTmp,IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION|LR_LOADFROMFILE); } + if (hbmp) bExternalBitmap = TRUE; else { - hbmp = LoadImage(hInstance,MAKEINTRESOURCE(IDR_MAINWND),IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION); - hbmpCopy = CopyImage(hbmp,IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION); + LPWSTR toolBarIntRes = (iHighDpiToolBar > 0) ? MAKEINTRESOURCE(IDR_MAINWND2) : MAKEINTRESOURCE(IDR_MAINWND); + hbmp = LoadImage(hInstance, toolBarIntRes, IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION); + hbmpCopy = CopyImage(hbmp, IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION); } GetObject(hbmp,sizeof(BITMAP),&bmp); if (!IsXP()) @@ -5849,7 +5852,18 @@ void LoadSettings() dwFileCheckInverval = IniSectionGetInt(pIniSection,L"FileCheckInverval",2000); dwAutoReloadTimeout = IniSectionGetInt(pIniSection,L"AutoReloadTimeout",2000); + int ResX = GetSystemMetrics(SM_CXSCREEN); + int ResY = GetSystemMetrics(SM_CYSCREEN); + LoadIniSection(L"Toolbar Images",pIniSection,cchIniSection); + + iHighDpiToolBar = IniSectionGetInt(pIniSection, L"HighDpiToolBar", -1); + iHighDpiToolBar = max(min(iHighDpiToolBar, 1), -1); + if (iHighDpiToolBar < 0) { // undefined: derermine high DPI (higher than Full-HD) + if ((ResX > 1920) && (ResY > 1080)) + iHighDpiToolBar = 1; + } + IniSectionGetString(pIniSection,L"BitmapDefault",L"", tchToolbarBitmap,COUNTOF(tchToolbarBitmap)); IniSectionGetString(pIniSection,L"BitmapHot",L"", @@ -5861,9 +5875,6 @@ void LoadSettings() WCHAR tchPosX[32], tchPosY[32], tchSizeX[32], tchSizeY[32], tchMaximized[32]; - int ResX = GetSystemMetrics(SM_CXSCREEN); - int ResY = GetSystemMetrics(SM_CYSCREEN); - wsprintf(tchPosX,L"%ix%i PosX",ResX,ResY); wsprintf(tchPosY,L"%ix%i PosY",ResX,ResY); wsprintf(tchSizeX,L"%ix%i SizeX",ResX,ResY); diff --git a/src/Notepad3.rc b/src/Notepad3.rc index 8057659a7..8162f598d 100644 --- a/src/Notepad3.rc +++ b/src/Notepad3.rc @@ -12,7 +12,7 @@ #undef APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// -// English (United States) resources +// Englisch (USA) resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US @@ -57,6 +57,8 @@ IDB_PICK BITMAP "..\\res\\Pick.bmp" IDB_ENCODING BITMAP "..\\res\\Encoding.bmp" +IDR_MAINWND2 BITMAP "..\\res\\Toolbar2.bmp" + ///////////////////////////////////////////////////////////////////////////// // @@ -97,18 +99,18 @@ BEGIN MENUITEM SEPARATOR POPUP "&Encoding" BEGIN - MENUITEM "&ANSI", IDM_ENCODING_ANSI - MENUITEM "&Unicode", IDM_ENCODING_UNICODE - MENUITEM "Unicode &Big Endian", IDM_ENCODING_UNICODEREV - MENUITEM "UTF-&8\tShift+F8", IDM_ENCODING_UTF8 - MENUITEM "UTF-8 with &Signature", IDM_ENCODING_UTF8SIGN - MENUITEM "&More...\tF9", IDM_ENCODING_SELECT + MENUITEM "&ANSI", IDM_ENCODING_ANSI + MENUITEM "&Unicode", IDM_ENCODING_UNICODE + MENUITEM "Unicode &Big Endian", IDM_ENCODING_UNICODEREV + MENUITEM "UTF-&8\tShift+F8", IDM_ENCODING_UTF8 + MENUITEM "UTF-8 with &Signature", IDM_ENCODING_UTF8SIGN + MENUITEM "&More...\tF9", IDM_ENCODING_SELECT MENUITEM SEPARATOR - MENUITEM "Recode to &ANSI\tCtrl-Shift+A", CMD_RECODEANSI + MENUITEM "Recode to &ANSI\tCtrl-Shift+A", CMD_RECODEANSI MENUITEM "Recode to &Default\tCtrl-Alt-F", CMD_RECODEDEFAULT - MENUITEM "&Recode...\tF8", IDM_ENCODING_RECODE + MENUITEM "&Recode...\tF8", IDM_ENCODING_RECODE MENUITEM SEPARATOR - MENUITEM "Set &Default...", IDM_ENCODING_SETDEFAULT + MENUITEM "Set &Default...", IDM_ENCODING_SETDEFAULT END POPUP "Line Endin&gs" BEGIN @@ -295,21 +297,21 @@ BEGIN END POPUP "&Settings" BEGIN - MENUITEM "Insert Tabs as &Spaces", IDM_VIEW_TABSASSPACES - MENUITEM "&Tab Settings...\tCtrl+T", IDM_VIEW_TABSETTINGS - MENUITEM "&Word Wrap Settings...", IDM_VIEW_WORDWRAPSETTINGS - MENUITEM "&Long Line Settings...", IDM_VIEW_LONGLINESETTINGS - MENUITEM "Auto In&dent Text", IDM_VIEW_AUTOINDENTTEXT + MENUITEM "Insert Tabs as &Spaces", IDM_VIEW_TABSASSPACES + MENUITEM "&Tab Settings...\tCtrl+T", IDM_VIEW_TABSETTINGS + MENUITEM "&Word Wrap Settings...", IDM_VIEW_WORDWRAPSETTINGS + MENUITEM "&Long Line Settings...", IDM_VIEW_LONGLINESETTINGS + MENUITEM "Auto In&dent Text", IDM_VIEW_AUTOINDENTTEXT MENUITEM "Auto Close &HTML/XML\tCtrl+Shift+H", IDM_VIEW_AUTOCLOSETAGS - MENUITEM "Auto Complete Wo&rds", IDM_VIEW_AUTOCOMPLETEWORDS + MENUITEM "Auto Complete Wo&rds", IDM_VIEW_AUTOCOMPLETEWORDS MENUITEM SEPARATOR - MENUITEM "&Reuse Window", IDM_VIEW_REUSEWINDOW - MENUITEM "Sticky Window &Position", IDM_VIEW_STICKYWINPOS - MENUITEM "&Always On Top\tAlt+T", IDM_VIEW_ALWAYSONTOP - MENUITEM "Minimi&ze To Tray", IDM_VIEW_MINTOTRAY + MENUITEM "&Reuse Window", IDM_VIEW_REUSEWINDOW + MENUITEM "Sticky Window &Position", IDM_VIEW_STICKYWINPOS + MENUITEM "&Always On Top\tAlt+T", IDM_VIEW_ALWAYSONTOP + MENUITEM "Minimi&ze To Tray", IDM_VIEW_MINTOTRAY MENUITEM "Transparent &Mode\tCtrl+Numpad_*", IDM_VIEW_TRANSPARENT MENUITEM SEPARATOR - MENUITEM "Single &File Instance", IDM_VIEW_SINGLEFILEINSTANCE + MENUITEM "Single &File Instance", IDM_VIEW_SINGLEFILEINSTANCE MENUITEM "File &Change Notification...\tAlt+F5", IDM_VIEW_CHANGENOTIFY POPUP "Window Title Displa&y" BEGIN @@ -578,7 +580,7 @@ BEGIN DEFPUSHBUTTON "OK",IDOK,195,204,50,14 ICON IDR_MAINWND,IDC_STATIC,7,7,21,20 LTEXT "",IDC_VERSION,45,10,200,17 - LTEXT "Scintilla Library Version:", IDC_SCI_VERSION, 45, 24, 200, 8 + LTEXT "Scintilla Library Version:",IDC_SCI_VERSION,45,24,200,8 LTEXT "Compiled with:",IDC_COMPILER2,45,35,200,8 LTEXT "",IDC_COMPILER,96,35,200,8 LTEXT "",IDC_COPYRIGHT,45,55,200,8 @@ -1812,12 +1814,12 @@ BEGIN 63257 "XML Element Text" END -#endif // English (United States) resources +#endif // Englisch (USA) resources ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// -// German (Switzerland) resources +// Deutsch (Schweiz) resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DES) LANGUAGE LANG_GERMAN, SUBLANG_GERMAN_SWISS @@ -1846,7 +1848,7 @@ END #endif // APSTUDIO_INVOKED -#endif // German (Switzerland) resources +#endif // Deutsch (Schweiz) resources ///////////////////////////////////////////////////////////////////////////// diff --git a/src/Notepad3_VS2017.vcxproj b/src/Notepad3_VS2017.vcxproj index 60b9fd9b5..047b433b7 100644 --- a/src/Notepad3_VS2017.vcxproj +++ b/src/Notepad3_VS2017.vcxproj @@ -288,6 +288,7 @@ + diff --git a/src/resource.h b/src/resource.h index 31ec37066..30da10698 100644 --- a/src/resource.h +++ b/src/resource.h @@ -1,6 +1,6 @@ //{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by Notepad3.rc +// Von Microsoft Visual C++ generierte Includedatei. +// Verwendet durch Notepad3.rc // #define IDR_MAINWND 100 #define IDC_FINDTEXT 100 @@ -119,6 +119,7 @@ #define IDC_WILDCARDHELP 153 #define IDC_WILDCARDSEARCH 154 #define IDC_SCI_VERSION 155 +#define IDR_MAINWND2 156 #define IDACC_FIND 200 #define IDACC_REPLACE 201 #define IDACC_SAVEPOS 202 @@ -453,7 +454,7 @@ #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NO_MFC 1 -#define _APS_NEXT_RESOURCE_VALUE 0 +#define _APS_NEXT_RESOURCE_VALUE 3 #define _APS_NEXT_COMMAND_VALUE 5 #define _APS_NEXT_CONTROL_VALUE 0 #define _APS_NEXT_SYMED_VALUE 0