Skip to content

Commit

Permalink
Make "Never" button mandatory in update dialog
Browse files Browse the repository at this point in the history
And make dialog always modal.
  • Loading branch information
donho committed Sep 17, 2022
1 parent 57ea8ba commit 9c86a33
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
10 changes: 5 additions & 5 deletions src/gup.rc
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,16 @@ BEGIN
PUSHBUTTON "Cancel",IDCANCEL,134,66,50,14
END

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

IDD_UPDATE_DLG DIALOGEX 0, 0, 200, 110
Expand Down
26 changes: 13 additions & 13 deletions src/winmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ LRESULT CALLBACK progressBarDlgProc(HWND hWndDlg, UINT Msg, WPARAM wParam, LPARA
}


LRESULT CALLBACK yesNoNeverDlgProc(HWND hWndDlg, UINT message, WPARAM wParam, LPARAM)
LRESULT CALLBACK yesNoNeverDlgProc(HWND hWndDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
Expand All @@ -600,6 +600,11 @@ LRESULT CALLBACK yesNoNeverDlgProc(HWND hWndDlg, UINT message, WPARAM wParam, LP
if (thirdDoUpdateDlgButtonLabel != L"")
::SetDlgItemText(hWndDlg, IDCANCEL, thirdDoUpdateDlgButtonLabel.c_str());

if (lParam)
{
::SetDlgItemText(hWndDlg, IDC_YESNONEVERMSG, (LPCWSTR)lParam);
}

goToScreenCenter(hWndDlg);
return TRUE;
}
Expand Down Expand Up @@ -1063,13 +1068,16 @@ std::wstring productVersionToFileVersion(const std::wstring& productVersion)
return fileVersion;
}


#ifdef _DEBUG
#define WRITE_LOG(fn, suffix, log) writeLog(fn, suffix, log);
#else
#define WRITE_LOG(fn, suffix, log)
#endif

// Definition from Notepad++
#define NPPMSG (WM_USER + 1000)
#define NPPM_DISABLEAUTOUPDATE (NPPMSG + 95) // 2119 in decimal

int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR lpszCmdLine, int)
{
/*
Expand Down Expand Up @@ -1368,15 +1376,10 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR lpszCmdLine, int)
updateAvailable += L"\n\n" + versionCurrent;
updateAvailable += L"\n" + versionNew;

int thirdButtonCmd = gupParams.get3rdButtonCmd();
thirdDoUpdateDlgButtonLabel = gupParams.get3rdButtonLabel();

int dlAnswer = 0;

if (!thirdButtonCmd)
dlAnswer = ::MessageBox(isModal ? hApp : NULL, updateAvailable.c_str(), gupParams.getMessageBoxTitle().c_str(), MB_YESNO);
else
dlAnswer = static_cast<int32_t>(::DialogBox(hInst, MAKEINTRESOURCE(IDD_YESNONEVERDLG), isModal ? hApp : NULL, reinterpret_cast<DLGPROC>(yesNoNeverDlgProc)));
dlAnswer = static_cast<int32_t>(::DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_YESNONEVERDLG), hApp, reinterpret_cast<DLGPROC>(yesNoNeverDlgProc), (LPARAM)updateAvailable.c_str()));

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

if (dlAnswer == IDCANCEL)
{
if (gupParams.getClassName() != L"")
if (hApp)
{
if (hApp)
{
::SendMessage(hApp, thirdButtonCmd, gupParams.get3rdButtonWparam(), gupParams.get3rdButtonLparam());
}
::SendMessage(hApp, NPPM_DISABLEAUTOUPDATE, 0, 0);
}
return 0;
}
Expand Down

0 comments on commit 9c86a33

Please sign in to comment.