config number for status dialog is now stored as property

pull/1/head
Heiko Hund 2009-02-05 14:22:57 +00:00
parent ac6c155243
commit b8f520be05
11 changed files with 17 additions and 22 deletions

View File

@ -86,7 +86,6 @@ BEGIN
PUSHBUTTON "Trennen", ID_DISCONNECT, 50, 190, 50, 14 PUSHBUTTON "Trennen", ID_DISCONNECT, 50, 190, 50, 14
PUSHBUTTON "Neu Verbinden", ID_RESTART, 150, 190, 50, 14 PUSHBUTTON "Neu Verbinden", ID_RESTART, 150, 190, 50, 14
PUSHBUTTON "Minimieren", ID_HIDE, 100, 190, 50, 14 PUSHBUTTON "Minimieren", ID_HIDE, 100, 190, 50, 14
LTEXT "", ID_TXT_CONFIG, 0, 0, 0, 0
END END
/* Change Passphrase Dialog */ /* Change Passphrase Dialog */

View File

@ -81,7 +81,6 @@ BEGIN
PUSHBUTTON "Disconnect", ID_DISCONNECT, 50, 190, 50, 14 PUSHBUTTON "Disconnect", ID_DISCONNECT, 50, 190, 50, 14
PUSHBUTTON "Reconnect", ID_RESTART, 150, 190, 50, 14 PUSHBUTTON "Reconnect", ID_RESTART, 150, 190, 50, 14
PUSHBUTTON "Hide", ID_HIDE, 100, 190, 50, 14 PUSHBUTTON "Hide", ID_HIDE, 100, 190, 50, 14
LTEXT "", ID_TXT_CONFIG, 0, 0, 0, 0
END END
/* Change Passphrase Dialog */ /* Change Passphrase Dialog */

View File

@ -80,7 +80,6 @@ BEGIN
PUSHBUTTON "Desconectar", ID_DISCONNECT, 50, 190, 50, 14 PUSHBUTTON "Desconectar", ID_DISCONNECT, 50, 190, 50, 14
PUSHBUTTON "Reconectar", ID_RESTART, 150, 190, 50, 14 PUSHBUTTON "Reconectar", ID_RESTART, 150, 190, 50, 14
PUSHBUTTON "Ocultar", ID_HIDE, 100, 190, 50, 14 PUSHBUTTON "Ocultar", ID_HIDE, 100, 190, 50, 14
LTEXT "", ID_TXT_CONFIG, 0, 0, 0, 0
END END
/* Change Passphrase Dialog */ /* Change Passphrase Dialog */

View File

@ -79,7 +79,6 @@ BEGIN
PUSHBUTTON "Déconnecter", ID_DISCONNECT, 50, 190, 50, 14 PUSHBUTTON "Déconnecter", ID_DISCONNECT, 50, 190, 50, 14
PUSHBUTTON "Reconnecter", ID_RESTART, 150, 190, 50, 14 PUSHBUTTON "Reconnecter", ID_RESTART, 150, 190, 50, 14
PUSHBUTTON "Fermer", ID_HIDE, 100, 190, 50, 14 PUSHBUTTON "Fermer", ID_HIDE, 100, 190, 50, 14
LTEXT "", ID_TXT_CONFIG, 0, 0, 0, 0
END END
/* Change Passphrase Dialog */ /* Change Passphrase Dialog */

View File

@ -79,7 +79,6 @@ BEGIN
PUSHBUTTON "Disconnetti", ID_DISCONNECT, 50, 190, 50, 14 PUSHBUTTON "Disconnetti", ID_DISCONNECT, 50, 190, 50, 14
PUSHBUTTON "Riconnetti", ID_RESTART, 150, 190, 50, 14 PUSHBUTTON "Riconnetti", ID_RESTART, 150, 190, 50, 14
PUSHBUTTON "Nascondi", ID_HIDE, 100, 190, 50, 14 PUSHBUTTON "Nascondi", ID_HIDE, 100, 190, 50, 14
LTEXT "", ID_TXT_CONFIG, 0, 0, 0, 0
END END
/* Change Passphrase Dialog */ /* Change Passphrase Dialog */

View File

@ -79,7 +79,6 @@ BEGIN
PUSHBUTTON "Verbroken", ID_DISCONNECT, 50, 190, 50, 14 PUSHBUTTON "Verbroken", ID_DISCONNECT, 50, 190, 50, 14
PUSHBUTTON "Opnieuw verbinden", ID_RESTART, 150, 190, 50, 14 PUSHBUTTON "Opnieuw verbinden", ID_RESTART, 150, 190, 50, 14
PUSHBUTTON "Verbergen", ID_HIDE, 100, 190, 50, 14 PUSHBUTTON "Verbergen", ID_HIDE, 100, 190, 50, 14
LTEXT "", ID_TXT_CONFIG, 0, 0, 0, 0
END END
/* Change Passphrase Dialog */ /* Change Passphrase Dialog */

View File

@ -84,7 +84,6 @@ BEGIN
PUSHBUTTON "Koble fra", ID_DISCONNECT, 50, 190, 50, 14 PUSHBUTTON "Koble fra", ID_DISCONNECT, 50, 190, 50, 14
PUSHBUTTON "Koble til på nytt", ID_RESTART, 150, 190, 40, 14 PUSHBUTTON "Koble til på nytt", ID_RESTART, 150, 190, 40, 14
PUSHBUTTON "Skjul", ID_HIDE, 100, 190, 40, 14 PUSHBUTTON "Skjul", ID_HIDE, 100, 190, 40, 14
LTEXT "", ID_TXT_CONFIG, 0, 0, 0, 0
END END
/* Change Passphrase Dialog */ /* Change Passphrase Dialog */

View File

@ -80,7 +80,6 @@ BEGIN
PUSHBUTTON "Desconectar", ID_DISCONNECT, 50, 190, 50, 14 PUSHBUTTON "Desconectar", ID_DISCONNECT, 50, 190, 50, 14
PUSHBUTTON "Reconectar", ID_RESTART, 150, 190, 50, 14 PUSHBUTTON "Reconectar", ID_RESTART, 150, 190, 50, 14
PUSHBUTTON "Ocultar", ID_HIDE, 100, 190, 50, 14 PUSHBUTTON "Ocultar", ID_HIDE, 100, 190, 50, 14
LTEXT "", ID_TXT_CONFIG, 0, 0, 0, 0
END END
/* Change Passphrase Dialog */ /* Change Passphrase Dialog */

View File

@ -85,7 +85,6 @@ BEGIN
PUSHBUTTON "Koppla ner", ID_DISCONNECT, 50, 190, 50, 14 PUSHBUTTON "Koppla ner", ID_DISCONNECT, 50, 190, 50, 14
PUSHBUTTON "Återanslut", ID_RESTART, 150, 190, 40, 14 PUSHBUTTON "Återanslut", ID_RESTART, 150, 190, 40, 14
PUSHBUTTON "Göm", ID_HIDE, 100, 190, 40, 14 PUSHBUTTON "Göm", ID_HIDE, 100, 190, 40, 14
LTEXT "", ID_TXT_CONFIG, 0, 0, 0, 0
END END
/* Change Passphrase Dialog */ /* Change Passphrase Dialog */

View File

@ -42,11 +42,6 @@
#define ID_DISCONNECT 163 #define ID_DISCONNECT 163
#define ID_RESTART 164 #define ID_RESTART 164
#define ID_HIDE 165 #define ID_HIDE 165
/* A hidden textbox used to pass the config nr so dialog knows
* which connection to cancel. If anyone knows of another way
* to pass a variable to dialog, please let me know.
*/
#define ID_TXT_CONFIG 166
/* Change Passphrase Dialog */ /* Change Passphrase Dialog */
#define ID_DLG_CHGPASS 170 #define ID_DLG_CHGPASS 170

View File

@ -25,6 +25,7 @@
#include <windows.h> #include <windows.h>
#include <tchar.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <process.h> #include <process.h>
@ -436,11 +437,11 @@ void StopAllOpenVPN()
BOOL CALLBACK StatusDialogFunc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) BOOL CALLBACK StatusDialogFunc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{ {
BOOL Translated; static const TCHAR cfgProp[] = _T("config");
HWND hwndLogWindow; HWND hwndLogWindow;
RECT rect; RECT rect;
CHARFORMAT charformat; CHARFORMAT charformat;
int config; UINT config;
switch (msg) { switch (msg) {
@ -448,6 +449,9 @@ BOOL CALLBACK StatusDialogFunc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
/* Set Window Icon "DisConnected" */ /* Set Window Icon "DisConnected" */
SetStatusWinIcon(hwndDlg, ID_ICO_CONNECTING); SetStatusWinIcon(hwndDlg, ID_ICO_CONNECTING);
/* Set config number for this dialog */
SetProp(hwndDlg, cfgProp, (HANDLE) lParam);
/* Create LogWindow */ /* Create LogWindow */
hwndLogWindow = CreateWindowEx (0, RICHEDIT_CLASS, NULL, hwndLogWindow = CreateWindowEx (0, RICHEDIT_CLASS, NULL,
WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL | \ WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL | \
@ -506,7 +510,7 @@ BOOL CALLBACK StatusDialogFunc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
return TRUE; return TRUE;
case WM_COMMAND: case WM_COMMAND:
config=GetDlgItemInt(hwndDlg, ID_TXT_CONFIG, &Translated, FALSE); config = (UINT) GetProp(hwndDlg, cfgProp);
switch (LOWORD(wParam)) { switch (LOWORD(wParam)) {
case ID_DISCONNECT: case ID_DISCONNECT:
@ -515,7 +519,7 @@ BOOL CALLBACK StatusDialogFunc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
return TRUE; return TRUE;
case ID_HIDE: case ID_HIDE:
if (o.cnn[GetDlgItemInt(hwndDlg, ID_TXT_CONFIG, &Translated, FALSE)].connect_status != DISCONNECTED) if (o.cnn[config].connect_status != DISCONNECTED)
{ {
ShowWindow(hwndDlg, SW_HIDE); ShowWindow(hwndDlg, SW_HIDE);
} }
@ -524,6 +528,7 @@ BOOL CALLBACK StatusDialogFunc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
DestroyWindow(hwndDlg); DestroyWindow(hwndDlg);
} }
return TRUE; return TRUE;
case ID_RESTART: case ID_RESTART:
SetFocus(GetDlgItem(o.cnn[config].hwndStatus, ID_EDT_LOG)); SetFocus(GetDlgItem(o.cnn[config].hwndStatus, ID_EDT_LOG));
o.cnn[config].restart = true; o.cnn[config].restart = true;
@ -535,14 +540,15 @@ BOOL CALLBACK StatusDialogFunc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
case WM_SHOWWINDOW: case WM_SHOWWINDOW:
if (wParam == TRUE) if (wParam == TRUE)
{ {
config=GetDlgItemInt(hwndDlg, ID_TXT_CONFIG, &Translated, FALSE); config = (UINT) GetProp(hwndDlg, cfgProp);
if (o.cnn[config].hwndStatus) if (o.cnn[config].hwndStatus)
SetFocus(GetDlgItem(o.cnn[config].hwndStatus, ID_EDT_LOG)); SetFocus(GetDlgItem(o.cnn[config].hwndStatus, ID_EDT_LOG));
} }
return FALSE; return FALSE;
case WM_CLOSE: case WM_CLOSE:
if (o.cnn[GetDlgItemInt(hwndDlg, ID_TXT_CONFIG, &Translated, FALSE)].connect_status != DISCONNECTED) config = (UINT) GetProp(hwndDlg, cfgProp);
if (o.cnn[config].connect_status != DISCONNECTED)
{ {
ShowWindow(hwndDlg, SW_HIDE); ShowWindow(hwndDlg, SW_HIDE);
} }
@ -552,6 +558,10 @@ BOOL CALLBACK StatusDialogFunc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
} }
return TRUE; return TRUE;
case WM_NCDESTROY:
RemoveProp(hwndDlg, cfgProp);
break;
case WM_DESTROY: case WM_DESTROY:
PostQuitMessage(0); PostQuitMessage(0);
break; break;
@ -909,12 +919,11 @@ void ThreadOpenVPNStatus(int config)
else else
{ {
/* Create and Show Status Dialog */ /* Create and Show Status Dialog */
o.cnn[config].hwndStatus = CreateLocalizedDialog(ID_DLG_STATUS, StatusDialogFunc); o.cnn[config].hwndStatus = CreateLocalizedDialogParam(ID_DLG_STATUS, StatusDialogFunc, config);
if (!o.cnn[config].hwndStatus) if (!o.cnn[config].hwndStatus)
ExitThread(1); ExitThread(1);
/* UserInfo: Connecting */ /* UserInfo: Connecting */
SetDlgItemText(o.cnn[config].hwndStatus, ID_TXT_STATUS, LoadLocalizedString(IDS_NFO_STATE_CONNECTING)); SetDlgItemText(o.cnn[config].hwndStatus, ID_TXT_STATUS, LoadLocalizedString(IDS_NFO_STATE_CONNECTING));
SetDlgItemInt(o.cnn[config].hwndStatus, ID_TXT_CONFIG, (UINT)config, FALSE);
SetWindowText(o.cnn[config].hwndStatus, LoadLocalizedString(IDS_NFO_CONNECTION_XXX, conn_name)); SetWindowText(o.cnn[config].hwndStatus, LoadLocalizedString(IDS_NFO_CONNECTION_XXX, conn_name));
if (o.silent_connection[0]=='0') if (o.silent_connection[0]=='0')