mirror of https://github.com/OpenVPN/openvpn-gui
localize buttons in message boxes when possible
parent
beead0e1a4
commit
82eb645a5e
|
@ -40,7 +40,7 @@
|
||||||
|
|
||||||
extern options_t o;
|
extern options_t o;
|
||||||
|
|
||||||
static const LANGID fallbackLangId = MAKELANGID(LANG_ENGLISH, SUBLANG_NEUTRAL);
|
static const LANGID fallbackLangId = MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT);
|
||||||
static LANGID gui_language;
|
static LANGID gui_language;
|
||||||
|
|
||||||
static HRSRC
|
static HRSRC
|
||||||
|
@ -176,12 +176,30 @@ LoadLocalizedStringBuf(PTSTR buffer, int bufferSize, const UINT stringId, ...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
__ShowLocalizedMsgEx(const UINT type, LPCTSTR caption, const UINT stringId, va_list args)
|
||||||
|
{
|
||||||
|
return MessageBoxEx(NULL, __LoadLocalizedString(stringId, args), caption,
|
||||||
|
type | MB_SETFOREGROUND, GetGUILanguage());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
ShowLocalizedMsgEx(const UINT type, LPCTSTR caption, const UINT stringId, ...)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
va_start(args, stringId);
|
||||||
|
return __ShowLocalizedMsgEx(type, caption, stringId, args);
|
||||||
|
va_end(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowLocalizedMsg(const UINT stringId, ...)
|
ShowLocalizedMsg(const UINT stringId, ...)
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, stringId);
|
va_start(args, stringId);
|
||||||
MessageBox(NULL, __LoadLocalizedString(stringId, args), _T(PACKAGE_NAME), MB_OK | MB_SETFOREGROUND);
|
__ShowLocalizedMsgEx(MB_OK, _T(PACKAGE_NAME), stringId, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
PTSTR LoadLocalizedString(const UINT, ...);
|
PTSTR LoadLocalizedString(const UINT, ...);
|
||||||
int LoadLocalizedStringBuf(PTSTR, const int, const UINT, ...);
|
int LoadLocalizedStringBuf(PTSTR, const int, const UINT, ...);
|
||||||
void ShowLocalizedMsg(const UINT, ...);
|
void ShowLocalizedMsg(const UINT, ...);
|
||||||
|
int ShowLocalizedMsgEx(const UINT, LPCTSTR, const UINT, ...);
|
||||||
HICON LoadLocalizedIcon(const UINT);
|
HICON LoadLocalizedIcon(const UINT);
|
||||||
LPCDLGTEMPLATE LocalizedDialogResource(const UINT);
|
LPCDLGTEMPLATE LocalizedDialogResource(const UINT);
|
||||||
INT_PTR LocalizedDialogBoxParam(const UINT, DLGPROC, const LPARAM);
|
INT_PTR LocalizedDialogBoxParam(const UINT, DLGPROC, const LPARAM);
|
||||||
|
|
36
main.c
36
main.c
|
@ -471,32 +471,26 @@ ShowSettingsDialog()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CloseApplication(HWND hwnd)
|
void
|
||||||
|
CloseApplication(HWND hwnd)
|
||||||
{
|
{
|
||||||
int i, ask_exit=0;
|
int i;
|
||||||
|
|
||||||
if (o.service_state == service_connected)
|
if (o.service_state == service_connected
|
||||||
|
&& ShowLocalizedMsgEx(MB_YESNO, _T("Exit OpenVPN"), IDS_NFO_SERVICE_ACTIVE_EXIT) == IDNO)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (i = 0; i < o.num_configs; i++)
|
||||||
{
|
{
|
||||||
if (MessageBox(NULL, LoadLocalizedString(IDS_NFO_SERVICE_ACTIVE_EXIT), _T("Exit OpenVPN"), MB_YESNO) == IDNO)
|
if (o.conn[i].state == disconnected)
|
||||||
{
|
continue;
|
||||||
return;
|
|
||||||
}
|
/* Ask for confirmation if still connected */
|
||||||
|
if (ShowLocalizedMsgEx(MB_YESNO, _T("Exit OpenVPN"), IDS_NFO_ACTIVE_CONN_EXIT) == IDNO)
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=0; i < o.num_configs; i++) {
|
DestroyWindow(hwnd);
|
||||||
if (o.conn[i].state != disconnected) {
|
|
||||||
ask_exit=1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (ask_exit) {
|
|
||||||
/* aks for confirmation */
|
|
||||||
if (MessageBox(NULL, LoadLocalizedString(IDS_NFO_ACTIVE_CONN_EXIT), _T("Exit OpenVPN"), MB_YESNO) == IDNO)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
DestroyWindow(hwnd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
|
|
@ -46,7 +46,7 @@ add_option(options_t *options, int i, TCHAR **p)
|
||||||
{
|
{
|
||||||
TCHAR caption[200];
|
TCHAR caption[200];
|
||||||
LoadLocalizedStringBuf(caption, _countof(caption), IDS_NFO_USAGECAPTION);
|
LoadLocalizedStringBuf(caption, _countof(caption), IDS_NFO_USAGECAPTION);
|
||||||
MessageBox(NULL, LoadLocalizedString(IDS_NFO_USAGE), caption, MB_OK);
|
ShowLocalizedMsgEx(MB_OK, caption, IDS_NFO_USAGE);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
else if (streq(p[0], _T("connect")) && p[1])
|
else if (streq(p[0], _T("connect")) && p[1])
|
||||||
|
|
10
passphrase.c
10
passphrase.c
|
@ -377,12 +377,10 @@ ChangePassphraseDialogFunc(HWND hwndDlg, UINT msg, WPARAM wParam, UNUSED LPARAM
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if the new password is empty. */
|
/* Confirm if the new password is empty. */
|
||||||
if (NewPasswordLengh(hwndDlg) == 0)
|
if (NewPasswordLengh(hwndDlg) == 0
|
||||||
{
|
&& ShowLocalizedMsgEx(MB_YESNO, _T(PACKAGE_NAME), IDS_NFO_EMPTY_PWD) == IDNO)
|
||||||
if (MessageBox(NULL, LoadLocalizedString(IDS_NFO_EMPTY_PWD), _T(PACKAGE_NAME), MB_YESNO) != IDYES)
|
break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
GetDlgItemText(hwndDlg, ID_TXT_KEYFILE, keyfile, _countof(keyfile) - 1);
|
GetDlgItemText(hwndDlg, ID_TXT_KEYFILE, keyfile, _countof(keyfile) - 1);
|
||||||
keyfile_format=GetDlgItemInt(hwndDlg, ID_TXT_KEYFORMAT, &Translated, FALSE);
|
keyfile_format=GetDlgItemInt(hwndDlg, ID_TXT_KEYFORMAT, &Translated, FALSE);
|
||||||
|
|
3
tray.c
3
tray.c
|
@ -197,8 +197,7 @@ OnNotifyTray(LPARAM lParam)
|
||||||
MyStartService();
|
MyStartService();
|
||||||
}
|
}
|
||||||
else if (o.service_state == service_connected
|
else if (o.service_state == service_connected
|
||||||
&& MessageBox(NULL, LoadLocalizedString(IDS_MENU_ASK_STOP_SERVICE),
|
&& ShowLocalizedMsgEx(MB_YESNO, _T(PACKAGE_NAME), IDS_MENU_ASK_STOP_SERVICE) == IDYES) {
|
||||||
_T(PACKAGE_NAME), MB_YESNO | MB_SETFOREGROUND) == IDYES) {
|
|
||||||
MyStopService();
|
MyStopService();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue