From 6bea8e5e8ffa0c4312114c33fbeb1bc0914f45f5 Mon Sep 17 00:00:00 2001 From: Rainer Kottenhoff Date: Tue, 20 Nov 2018 15:01:21 +0100 Subject: [PATCH] + fix: load resources before displaying command-line-help dialog + fix: center dialog in case of missing parent window --- src/Dialogs.c | 7 +++++-- src/Notepad3.c | 13 +++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/Dialogs.c b/src/Dialogs.c index 015e77ebb..4f9499860 100644 --- a/src/Dialogs.c +++ b/src/Dialogs.c @@ -3137,7 +3137,10 @@ void CenterDlgInParent(HWND hDlg) HWND const hParent = GetParent(hDlg); RECT rcParent; - GetWindowRect(hParent, &rcParent); + if (hParent) + GetWindowRect(hParent, &rcParent); + else + GetWindowRect(GetDesktopWindow(), &rcParent); HMONITOR const hMonitor = MonitorFromRect(&rcParent, MONITOR_DEFAULTTONEAREST); @@ -3165,7 +3168,7 @@ void CenterDlgInParent(HWND hDlg) SetWindowPos(hDlg, NULL, clampi(x, xMin, xMax), clampi(y, yMin, yMax), 0, 0, SWP_NOZORDER | SWP_NOSIZE); - //SnapToDefaultButton(hDlg); + //~SnapToDefaultButton(hDlg); } diff --git a/src/Notepad3.c b/src/Notepad3.c index ca6673aa1..a31193f4a 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -555,12 +555,6 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, // set AppUserModelID PrivateSetCurrentProcessExplicitAppUserModelID(Settings2.AppUserModelID); - // Command Line Help Dialog - if (s_flagDisplayHelp) { - DisplayCmdLineHelp(NULL); - return 0; - } - // Adapt window class name if (s_flagIsElevated) { StringCchCat(s_wchWndClass, COUNTOF(s_wchWndClass), L"U"); @@ -651,6 +645,13 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, s_hRichEdit = LoadLibrary(L"MSFTEDIT.DLL"); // Use "RichEdit50W" for control in common_res.h } + // Command Line Help Dialog + if (s_flagDisplayHelp) { + DisplayCmdLineHelp(NULL); + _CleanUpResources(NULL, false); + return 0; + } + s_msgTaskbarCreated = RegisterWindowMessage(L"TaskbarCreated"); if (!Globals.hDlgIcon) {