Skip to content

Commit 9c86a33

Browse files
committed
Make "Never" button mandatory in update dialog
And make dialog always modal.
1 parent 57ea8ba commit 9c86a33

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

src/gup.rc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,16 @@ BEGIN
6969
PUSHBUTTON "Cancel",IDCANCEL,134,66,50,14
7070
END
7171

72-
IDD_YESNONEVERDLG DIALOGEX 0, 0, 285, 94
72+
IDD_YESNONEVERDLG DIALOGEX 0, 0, 270, 94
7373
STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
7474
EXSTYLE WS_EX_TOOLWINDOW | WS_EX_WINDOWEDGE
7575
CAPTION "Update available"
7676
FONT 8, "MS Shell Dlg", 0, 0, 0x1
7777
BEGIN
78-
LTEXT "An update package is available, do you want to download it?",IDC_YESNONEVERMSG,13,20,259,16
79-
PUSHBUTTON "Yes",IDYES,50,60,50,14
80-
PUSHBUTTON "No",IDNO,110,60,50,14
81-
PUSHBUTTON "Never",IDCANCEL,170,60,50,14
78+
LTEXT "An update package is available, do you want to download it?",IDC_YESNONEVERMSG,15,15,250,64
79+
PUSHBUTTON "Yes",IDYES,50,70,50,14
80+
PUSHBUTTON "No",IDNO,110,70,50,14
81+
PUSHBUTTON "Never",IDCANCEL,170,70,50,14
8282
END
8383

8484
IDD_UPDATE_DLG DIALOGEX 0, 0, 200, 110

src/winmain.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ LRESULT CALLBACK progressBarDlgProc(HWND hWndDlg, UINT Msg, WPARAM wParam, LPARA
591591
}
592592

593593

594-
LRESULT CALLBACK yesNoNeverDlgProc(HWND hWndDlg, UINT message, WPARAM wParam, LPARAM)
594+
LRESULT CALLBACK yesNoNeverDlgProc(HWND hWndDlg, UINT message, WPARAM wParam, LPARAM lParam)
595595
{
596596
switch (message)
597597
{
@@ -600,6 +600,11 @@ LRESULT CALLBACK yesNoNeverDlgProc(HWND hWndDlg, UINT message, WPARAM wParam, LP
600600
if (thirdDoUpdateDlgButtonLabel != L"")
601601
::SetDlgItemText(hWndDlg, IDCANCEL, thirdDoUpdateDlgButtonLabel.c_str());
602602

603+
if (lParam)
604+
{
605+
::SetDlgItemText(hWndDlg, IDC_YESNONEVERMSG, (LPCWSTR)lParam);
606+
}
607+
603608
goToScreenCenter(hWndDlg);
604609
return TRUE;
605610
}
@@ -1063,13 +1068,16 @@ std::wstring productVersionToFileVersion(const std::wstring& productVersion)
10631068
return fileVersion;
10641069
}
10651070

1066-
10671071
#ifdef _DEBUG
10681072
#define WRITE_LOG(fn, suffix, log) writeLog(fn, suffix, log);
10691073
#else
10701074
#define WRITE_LOG(fn, suffix, log)
10711075
#endif
10721076

1077+
// Definition from Notepad++
1078+
#define NPPMSG (WM_USER + 1000)
1079+
#define NPPM_DISABLEAUTOUPDATE (NPPMSG + 95) // 2119 in decimal
1080+
10731081
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR lpszCmdLine, int)
10741082
{
10751083
/*
@@ -1368,15 +1376,10 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR lpszCmdLine, int)
13681376
updateAvailable += L"\n\n" + versionCurrent;
13691377
updateAvailable += L"\n" + versionNew;
13701378

1371-
int thirdButtonCmd = gupParams.get3rdButtonCmd();
13721379
thirdDoUpdateDlgButtonLabel = gupParams.get3rdButtonLabel();
13731380

13741381
int dlAnswer = 0;
1375-
1376-
if (!thirdButtonCmd)
1377-
dlAnswer = ::MessageBox(isModal ? hApp : NULL, updateAvailable.c_str(), gupParams.getMessageBoxTitle().c_str(), MB_YESNO);
1378-
else
1379-
dlAnswer = static_cast<int32_t>(::DialogBox(hInst, MAKEINTRESOURCE(IDD_YESNONEVERDLG), isModal ? hApp : NULL, reinterpret_cast<DLGPROC>(yesNoNeverDlgProc)));
1382+
dlAnswer = static_cast<int32_t>(::DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_YESNONEVERDLG), hApp, reinterpret_cast<DLGPROC>(yesNoNeverDlgProc), (LPARAM)updateAvailable.c_str()));
13801383

13811384
if (dlAnswer == IDNO)
13821385
{
@@ -1385,12 +1388,9 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR lpszCmdLine, int)
13851388

13861389
if (dlAnswer == IDCANCEL)
13871390
{
1388-
if (gupParams.getClassName() != L"")
1391+
if (hApp)
13891392
{
1390-
if (hApp)
1391-
{
1392-
::SendMessage(hApp, thirdButtonCmd, gupParams.get3rdButtonWparam(), gupParams.get3rdButtonLparam());
1393-
}
1393+
::SendMessage(hApp, NPPM_DISABLEAUTOUPDATE, 0, 0);
13941394
}
13951395
return 0;
13961396
}

0 commit comments

Comments
 (0)