mirror of https://github.com/OpenVPN/openvpn-gui
Do not open multiple Settings Windows
- Do not allow more than one settings menu to be opened Signed-off-by: Selva Nair <selva.nair@gmail.com>pull/591/head
parent
71c0a251bf
commit
939cbfd5d5
30
main.c
30
main.c
|
@ -79,6 +79,9 @@ options_t o;
|
||||||
/* Workaround for ASLR on Windows */
|
/* Workaround for ASLR on Windows */
|
||||||
__declspec(dllexport) char aslr_workaround;
|
__declspec(dllexport) char aslr_workaround;
|
||||||
|
|
||||||
|
/* globals */
|
||||||
|
static HWND settings_window; /* Handle of Settings window */
|
||||||
|
|
||||||
static int
|
static int
|
||||||
VerifyAutoConnections()
|
VerifyAutoConnections()
|
||||||
{
|
{
|
||||||
|
@ -758,12 +761,31 @@ AboutDialogFunc(UNUSED HWND hDlg, UINT msg, UNUSED WPARAM wParam, LPARAM lParam)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int CALLBACK
|
||||||
|
SettingsPsCallback(HWND hwnd, UINT msg, UNUSED LPARAM lParam)
|
||||||
|
{
|
||||||
|
switch(msg)
|
||||||
|
{
|
||||||
|
case PSCB_INITIALIZED:
|
||||||
|
settings_window = hwnd;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ShowSettingsDialog()
|
ShowSettingsDialog()
|
||||||
{
|
{
|
||||||
PROPSHEETPAGE psp[4];
|
PROPSHEETPAGE psp[4];
|
||||||
int page_number = 0;
|
int page_number = 0;
|
||||||
|
|
||||||
|
if (settings_window && IsWindow(settings_window))
|
||||||
|
{
|
||||||
|
SetForegroundWindow(settings_window);
|
||||||
|
ShowWindow(settings_window, SW_SHOW);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* General tab */
|
/* General tab */
|
||||||
psp[page_number].dwSize = sizeof(PROPSHEETPAGE);
|
psp[page_number].dwSize = sizeof(PROPSHEETPAGE);
|
||||||
|
@ -807,7 +829,7 @@ ShowSettingsDialog()
|
||||||
|
|
||||||
PROPSHEETHEADER psh;
|
PROPSHEETHEADER psh;
|
||||||
psh.dwSize = sizeof(PROPSHEETHEADER);
|
psh.dwSize = sizeof(PROPSHEETHEADER);
|
||||||
psh.dwFlags = PSH_USEHICON | PSH_PROPSHEETPAGE | PSH_NOAPPLYNOW | PSH_NOCONTEXTHELP;
|
psh.dwFlags = PSH_USEHICON | PSH_PROPSHEETPAGE | PSH_NOAPPLYNOW | PSH_NOCONTEXTHELP | PSH_USECALLBACK;
|
||||||
psh.hwndParent = o.hWnd;
|
psh.hwndParent = o.hWnd;
|
||||||
psh.hInstance = o.hInstance;
|
psh.hInstance = o.hInstance;
|
||||||
psh.hIcon = LoadLocalizedIcon(ID_ICO_APP);
|
psh.hIcon = LoadLocalizedIcon(ID_ICO_APP);
|
||||||
|
@ -815,7 +837,7 @@ ShowSettingsDialog()
|
||||||
psh.nPages = page_number;
|
psh.nPages = page_number;
|
||||||
psh.nStartPage = 0;
|
psh.nStartPage = 0;
|
||||||
psh.ppsp = (LPCPROPSHEETPAGE) &psp;
|
psh.ppsp = (LPCPROPSHEETPAGE) &psp;
|
||||||
psh.pfnCallback = NULL;
|
psh.pfnCallback = SettingsPsCallback;
|
||||||
|
|
||||||
PropertySheet(&psh);
|
PropertySheet(&psh);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue