URL profile import: allow specifying owner window of message box

This will be used later when parent window
needs to be disabled when message box is displayed.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
pull/446/head
Lev Stipakov 2021-06-30 12:59:42 +03:00 committed by Selva Nair
parent 78ee9b981d
commit d6a622a023
8 changed files with 15 additions and 15 deletions

View File

@ -260,7 +260,7 @@ AuthorizeConfig(const connection_t *c)
return FALSE;
}
/* semaphore locked -- relase before return */
res = ShowLocalizedMsgEx(MB_YESNO|MB_ICONWARNING, TEXT(PACKAGE_NAME),
res = ShowLocalizedMsgEx(MB_YESNO|MB_ICONWARNING, NULL, TEXT(PACKAGE_NAME),
IDS_ERR_CONFIG_TRY_AUTHORIZE, c->config_name,
o.ovpn_admin_group);
if (res == IDYES)

View File

@ -215,19 +215,19 @@ LoadLocalizedStringBuf(PTSTR buffer, int bufferSize, const UINT stringId, ...)
static int
__ShowLocalizedMsgEx(const UINT type, LPCTSTR caption, const UINT stringId, va_list args)
__ShowLocalizedMsgEx(const UINT type, HANDLE parent, LPCTSTR caption, const UINT stringId, va_list args)
{
return MessageBoxEx(NULL, __LoadLocalizedString(stringId, args), caption,
return MessageBoxEx(parent, __LoadLocalizedString(stringId, args), caption,
type | MB_SETFOREGROUND, GetGUILanguage());
}
int
ShowLocalizedMsgEx(const UINT type, LPCTSTR caption, const UINT stringId, ...)
ShowLocalizedMsgEx(const UINT type, HANDLE parent, LPCTSTR caption, const UINT stringId, ...)
{
va_list args;
va_start(args, stringId);
int result = __ShowLocalizedMsgEx(type, caption, stringId, args);
int result = __ShowLocalizedMsgEx(type, parent, caption, stringId, args);
va_end(args);
return result;
}
@ -238,7 +238,7 @@ ShowLocalizedMsg(const UINT stringId, ...)
{
va_list args;
va_start(args, stringId);
__ShowLocalizedMsgEx(MB_OK, _T(PACKAGE_NAME), stringId, args);
__ShowLocalizedMsgEx(MB_OK, NULL, _T(PACKAGE_NAME), stringId, args);
va_end(args);
}

View File

@ -26,7 +26,7 @@ int LocalizedTime(const time_t, LPTSTR, size_t);
PTSTR LoadLocalizedString(const UINT, ...);
int LoadLocalizedStringBuf(PTSTR, const int, const UINT, ...);
void ShowLocalizedMsg(const UINT, ...);
int ShowLocalizedMsgEx(const UINT, LPCTSTR, const UINT, ...);
int ShowLocalizedMsgEx(const UINT, HANDLE, LPCTSTR, const UINT, ...);
HICON LoadLocalizedIconEx(const UINT, int cx, int cy);
HICON LoadLocalizedIcon(const UINT);
HICON LoadLocalizedSmallIcon(const UINT);

4
main.c
View File

@ -739,7 +739,7 @@ CloseApplication(HWND hwnd)
int i;
if (o.service_state == service_connected
&& ShowLocalizedMsgEx(MB_YESNO, _T("Exit OpenVPN"), IDS_NFO_SERVICE_ACTIVE_EXIT) == IDNO)
&& ShowLocalizedMsgEx(MB_YESNO, NULL, _T("Exit OpenVPN"), IDS_NFO_SERVICE_ACTIVE_EXIT) == IDNO)
return;
for (i = 0; i < o.num_configs; i++)
@ -748,7 +748,7 @@ CloseApplication(HWND hwnd)
continue;
/* Ask for confirmation if still connected */
if (ShowLocalizedMsgEx(MB_YESNO, _T("Exit OpenVPN"), IDS_NFO_ACTIVE_CONN_EXIT) == IDNO)
if (ShowLocalizedMsgEx(MB_YESNO, NULL, _T("Exit OpenVPN"), IDS_NFO_ACTIVE_CONN_EXIT) == IDNO)
return;
}

2
misc.c
View File

@ -671,7 +671,7 @@ ImportConfigFile(const TCHAR* source)
}
/* A file with same name exists. Ask the user whether to replace or not. */
if (ShowLocalizedMsgEx(MB_YESNO, _T(PACKAGE_NAME), IDS_NFO_IMPORT_OVERWRITE, fileName) == IDNO)
if (ShowLocalizedMsgEx(MB_YESNO, NULL, _T(PACKAGE_NAME), IDS_NFO_IMPORT_OVERWRITE, fileName) == IDNO)
return;
/* try again with overwrite allowed */

View File

@ -2454,7 +2454,7 @@ out:
void
ResetSavePasswords(connection_t *c)
{
if (ShowLocalizedMsgEx(MB_OKCANCEL, TEXT(PACKAGE_NAME), IDS_NFO_DELETE_PASS, c->config_name) == IDCANCEL)
if (ShowLocalizedMsgEx(MB_OKCANCEL, NULL, TEXT(PACKAGE_NAME), IDS_NFO_DELETE_PASS, c->config_name) == IDCANCEL)
return;
DeleteSavedPasswords(c->config_name);
c->flags &= ~(FLAG_SAVE_KEY_PASS | FLAG_SAVE_AUTH_PASS);

View File

@ -374,7 +374,7 @@ ChangePassphraseDialogFunc(HWND hwndDlg, UINT msg, WPARAM wParam, UNUSED LPARAM
/* Confirm if the new password is empty. */
if (NewPasswordLengh(hwndDlg) == 0)
{
if (ShowLocalizedMsgEx(MB_YESNO, _T(PACKAGE_NAME), IDS_NFO_EMPTY_PWD) == IDNO)
if (ShowLocalizedMsgEx(MB_YESNO, NULL, _T(PACKAGE_NAME), IDS_NFO_EMPTY_PWD) == IDNO)
break;
}
/* Else check minimum length of password */

2
tray.c
View File

@ -363,7 +363,7 @@ OnNotifyTray(LPARAM lParam)
MyStartService();
}
else if (o.service_state == service_connected
&& ShowLocalizedMsgEx(MB_YESNO, _T(PACKAGE_NAME), IDS_MENU_ASK_STOP_SERVICE) == IDYES) {
&& ShowLocalizedMsgEx(MB_YESNO, NULL, _T(PACKAGE_NAME), IDS_MENU_ASK_STOP_SERVICE) == IDYES) {
MyStopService();
}
}