Close button moonlights as Abort

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@7298 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
anders_k 2021-08-20 11:46:56 +00:00
parent 7fce1681df
commit 2c79d33b56
7 changed files with 29 additions and 20 deletions

View file

@ -216,6 +216,7 @@ Version History
- Use Consolas font if it exists
2.4.1
- Close button transforms to Abort when appropriate
- Prevent user from modifying the log

View file

@ -626,6 +626,17 @@ INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam
EnableUICommand(IDM_BROWSESCR, !!g_sdata.input_script);
break;
}
case WM_TIMER:
{
HWND hCtl;
switch(wParam) {
case TID_CONFIGURECLOSEORABORT:
SendMessage(hCtl = GetDlgItem(hwndDlg, IDCANCEL), WM_SETTEXT, 0, (LPARAM) (g_sdata.thread ? _T("&Abort") : _T("&Close")));
EnableWindow(hCtl, true);
return KillTimer(hwndDlg, wParam);
}
break;
}
case WM_COMMAND:
{
switch (LOWORD(wParam)) {
@ -750,6 +761,8 @@ INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam
return TRUE;
}
case IDCANCEL:
if (g_sdata.thread)
return PostMessage(hwndDlg, WM_COMMAND, IDM_CANCEL, 0);
case IDM_EXIT:
wParam = 0;
goto tryquitapp;

View file

@ -94,6 +94,7 @@ static inline bool IsWin95() { return SupportsW95() && (GetVersion() & (0x8000FF
#define WM_MAKENSIS_LOADSYMBOLSET (WM_USER+1002)
#define WM_MAKENSIS_SAVESYMBOLSET (WM_USER+1003)
#define WM_MAKENSIS_UPDATEUISTATE (WM_USER+1004)
#define TID_CONFIGURECLOSEORABORT 1
namespace MakensisAPI {
extern const TCHAR* SigintEventNameFmt;

View file

@ -14,10 +14,6 @@
#define IDS_EDITSCRIPT 10
#define IDS_BROWSESCR 11
#define IDS_CLEARLOG 12
#define IDS_NSISHOME 13
#define IDS_FORUM 15
#define IDS_NSISUPDATE 16
#define IDS_DOCS 17
#define IDS_SCRIPT 18
#define IDS_ZLIB 19
#define IDS_ZLIB_SOLID 20

View file

@ -380,14 +380,10 @@ BEGIN
IDS_EDITSCRIPT "Edit Script"
IDS_BROWSESCR "Open Script Folder"
IDS_CLEARLOG "Clear Log Window"
IDS_NSISHOME "NSIS Homepage"
IDS_FORUM "NSIS Forum"
END
STRINGTABLE
BEGIN
IDS_NSISUPDATE "NSIS Update"
IDS_DOCS "NSIS Users Manual"
IDS_SCRIPT "Defined in Script/Compiler Default"
IDS_ZLIB "ZLIB"
IDS_ZLIB_SOLID "ZLIB (solid)"

View file

@ -307,10 +307,11 @@ HWND GetComboEdit(HWND hCB)
return FindWindowEx(hCB, hList, 0, 0);
}
void EnableDisableItems(HWND hwnd, int on)
void EnableDisableItems(int on)
{
const HWND hCloseBtn = GetDlgItem(hwnd, IDCANCEL);
const HWND hTestBtn = GetDlgItem(hwnd, IDC_TEST);
HWND hwndDlg = g_sdata.hwnd;
const HWND hCloseBtn = GetDlgItem(hwndDlg, IDCANCEL);
const HWND hTestBtn = GetDlgItem(hwndDlg, IDC_TEST);
const HMENU hMenu = g_sdata.menu;
const UINT mf = (!on ? MF_GRAYED : MF_ENABLED);
const UINT nmf = (!on ? MF_ENABLED : MF_GRAYED);
@ -324,7 +325,7 @@ void EnableDisableItems(HWND hwnd, int on)
EnableMenuItem(hMenu, IDM_TEST, mf);
}
EnableMenuItem(hMenu, IDM_CANCEL, nmf);
EnableWindow(hCloseBtn, on);
EnableWindow(hCloseBtn, false);
static const PACKEDCMDID_T cmds [] = {
PACKCMDID(IDM_EXIT), PACKCMDID(IDM_LOADSCRIPT), PACKCMDID(IDM_EDITSCRIPT),
@ -339,15 +340,16 @@ void EnableDisableItems(HWND hwnd, int on)
EnableToolBarButton(id, on);
}
SendMessage(g_sdata.hwnd, WM_MAKENSIS_UPDATEUISTATE, 0 ,0);
SendMessage(hwndDlg, WM_MAKENSIS_UPDATEUISTATE, 0 ,0);
EnableMenuItem(hMenu, IDM_FILE, mf); // Disable the whole File menu because of the MRU list
DrawMenuBar(g_sdata.hwnd);
DrawMenuBar(hwndDlg);
HWND hFocus = g_sdata.focused_hwnd, hOptimal = hTestBtn;
if (on && hCloseBtn == hFocus) hFocus = hOptimal;
if (!IsWindowEnabled(hFocus)) hFocus = GetDlgItem(hwnd, IDC_LOGWIN);
SetDialogFocus(hwnd, hOptimal);
SetDialogFocus(hwnd, hFocus);
if (!IsWindowEnabled(hFocus)) hFocus = GetDlgItem(hwndDlg, IDC_LOGWIN);
SetDialogFocus(hwndDlg, hOptimal);
SetDialogFocus(hwndDlg, hFocus);
SetTimer(hwndDlg, TID_CONFIGURECLOSEORABORT, 1000, 0);
}
void SetCompressorStats()

View file

@ -76,9 +76,9 @@ void CenterOnParent(HWND hwnd);
void SetDialogFocus(HWND hDlg, HWND hCtl); // Use this and not SetFocus()!
#define DlgRet(hDlg, val) ( SetWindowLongPtr((hDlg), DWLP_MSGRESULT, (val)) | TRUE )
HWND GetComboEdit(HWND hCB);
#define DisableItems(hwnd) EnableDisableItems(hwnd, 0)
#define EnableItems(hwnd) EnableDisableItems(hwnd, 1)
void EnableDisableItems(HWND hwnd, int on);
#define DisableItems(hwnd) EnableDisableItems(((hwnd), 0))
#define EnableItems(hwnd) EnableDisableItems(((hwnd), 1))
void EnableDisableItems(int on);
bool OpenRegSettingsKey(HKEY &hKey, bool create = false);
#define CreateRegSettingsKey(refhkey) OpenRegSettingsKey((refhkey), true)
DWORD ReadRegSettingDW(LPCTSTR name, const DWORD defval);