service->stop_method &= ~method;\r
}\r
\r
-static inline void check_method_timeout(HWND tab, unsigned long control, unsigned long *timeout) {\r
+static inline void check_number(HWND tab, unsigned long control, unsigned long *timeout) {\r
BOOL translated;\r
unsigned long configured = GetDlgItemInt(tab, control, &translated, 0);\r
if (translated) *timeout = configured;\r
}\r
\r
+static inline void set_timeout_enabled(unsigned long control, unsigned long dependent) {\r
+ unsigned char enabled = 0;\r
+ if (SendDlgItemMessage(tablist[NSSM_TAB_SHUTDOWN], control, BM_GETCHECK, 0, 0) & BST_CHECKED) enabled = 1;\r
+ EnableWindow(GetDlgItem(tablist[NSSM_TAB_SHUTDOWN], dependent), enabled);\r
+}\r
+\r
+static inline void set_rotation_enabled(unsigned char enabled) {\r
+ EnableWindow(GetDlgItem(tablist[NSSM_TAB_ROTATION], IDC_ROTATE_SECONDS), enabled);\r
+ EnableWindow(GetDlgItem(tablist[NSSM_TAB_ROTATION], IDC_ROTATE_BYTES_LOW), enabled);\r
+}\r
+\r
static inline void check_io(TCHAR *name, TCHAR *buffer, unsigned long len, unsigned long control) {\r
if (! SendMessage(GetDlgItem(tablist[NSSM_TAB_IO], control), WM_GETTEXTLENGTH, 0, 0)) return;\r
if (GetDlgItemText(tablist[NSSM_TAB_IO], control, buffer, (int) len)) return;\r
check_stop_method(service, NSSM_STOP_METHOD_WINDOW, IDC_METHOD_WINDOW);\r
check_stop_method(service, NSSM_STOP_METHOD_THREADS, IDC_METHOD_THREADS);\r
check_stop_method(service, NSSM_STOP_METHOD_TERMINATE, IDC_METHOD_TERMINATE);\r
- check_method_timeout(tablist[NSSM_TAB_SHUTDOWN], IDC_KILL_CONSOLE, &service->kill_console_delay);\r
- check_method_timeout(tablist[NSSM_TAB_SHUTDOWN], IDC_KILL_WINDOW, &service->kill_window_delay);\r
- check_method_timeout(tablist[NSSM_TAB_SHUTDOWN], IDC_KILL_THREADS, &service->kill_threads_delay);\r
+ check_number(tablist[NSSM_TAB_SHUTDOWN], IDC_KILL_CONSOLE, &service->kill_console_delay);\r
+ check_number(tablist[NSSM_TAB_SHUTDOWN], IDC_KILL_WINDOW, &service->kill_window_delay);\r
+ check_number(tablist[NSSM_TAB_SHUTDOWN], IDC_KILL_THREADS, &service->kill_threads_delay);\r
\r
/* Get exit action stuff. */\r
- check_method_timeout(tablist[NSSM_TAB_EXIT], IDC_THROTTLE, &service->throttle_delay);\r
+ check_number(tablist[NSSM_TAB_EXIT], IDC_THROTTLE, &service->throttle_delay);\r
combo = GetDlgItem(tablist[NSSM_TAB_EXIT], IDC_APPEXIT);\r
service->default_exit_action = (unsigned long) SendMessage(combo, CB_GETCURSEL, 0, 0);\r
if (service->default_exit_action == CB_ERR) service->default_exit_action = 0;\r
/* Get rotation stuff. */\r
if (SendDlgItemMessage(tablist[NSSM_TAB_ROTATION], IDC_ROTATE, BM_GETCHECK, 0, 0) & BST_CHECKED) {\r
service->rotate_files = true;\r
- }\r
- if (SendDlgItemMessage(tablist[NSSM_TAB_ROTATION], IDC_ROTATE_SECONDS_ENABLED, BM_GETCHECK, 0, 0) & BST_CHECKED) {\r
- check_method_timeout(tablist[NSSM_TAB_ROTATION], IDC_ROTATE_SECONDS, &service->rotate_seconds);\r
- }\r
- if (SendDlgItemMessage(tablist[NSSM_TAB_ROTATION], IDC_ROTATE_BYTES_LOW_ENABLED, BM_GETCHECK, 0, 0) & BST_CHECKED) {\r
- check_method_timeout(tablist[NSSM_TAB_ROTATION], IDC_ROTATE_BYTES_LOW, &service->rotate_bytes_low);\r
+ check_number(tablist[NSSM_TAB_ROTATION], IDC_ROTATE_SECONDS, &service->rotate_seconds);\r
+ check_number(tablist[NSSM_TAB_ROTATION], IDC_ROTATE_BYTES_LOW, &service->rotate_bytes_low);\r
}\r
\r
/* Get environment. */\r
case WM_COMMAND:\r
HWND dlg;\r
TCHAR buffer[MAX_PATH];\r
- unsigned long state;\r
+ unsigned char enabled;\r
\r
switch (LOWORD(w)) {\r
/* Browse for application. */\r
}\r
break;\r
\r
- /* Browse for startup directory. */\r
+ /* Browse for startup directory. */\r
case IDC_BROWSE_DIR:\r
dlg = GetDlgItem(tab, IDC_DIR);\r
GetDlgItemText(tab, IDC_DIR, buffer, _countof(buffer));\r
browse(dlg, buffer, OFN_NOVALIDATE, NSSM_GUI_BROWSE_FILTER_DIRECTORIES, 0);\r
break;\r
\r
+ /* Shutdown methods. */\r
+ case IDC_METHOD_CONSOLE:\r
+ set_timeout_enabled(LOWORD(w), IDC_KILL_CONSOLE);\r
+ break;\r
+\r
+ case IDC_METHOD_WINDOW:\r
+ set_timeout_enabled(LOWORD(w), IDC_KILL_WINDOW);\r
+ break;\r
+\r
+ case IDC_METHOD_THREADS:\r
+ set_timeout_enabled(LOWORD(w), IDC_KILL_THREADS);\r
+ break;\r
+\r
/* Browse for stdin. */\r
case IDC_BROWSE_STDIN:\r
dlg = GetDlgItem(tab, IDC_STDIN);\r
\r
/* Rotation. */\r
case IDC_ROTATE:\r
- case IDC_ROTATE_SECONDS_ENABLED:\r
- case IDC_ROTATE_BYTES_LOW_ENABLED:\r
- if (SendDlgItemMessage(tab, LOWORD(w), BM_GETCHECK, 0, 0) & BST_CHECKED) state = BST_CHECKED;\r
- else state = BST_UNCHECKED;\r
- SendDlgItemMessage(tablist[NSSM_TAB_ROTATION], IDC_ROTATE, BM_SETCHECK, state, 0);\r
- SendDlgItemMessage(tablist[NSSM_TAB_ROTATION], IDC_ROTATE_SECONDS_ENABLED, BM_SETCHECK, state, 0);\r
- SendDlgItemMessage(tablist[NSSM_TAB_ROTATION], IDC_ROTATE_BYTES_LOW_ENABLED, BM_SETCHECK, state, 0);\r
+ if (SendDlgItemMessage(tab, LOWORD(w), BM_GETCHECK, 0, 0) & BST_CHECKED) enabled = 1;\r
+ else enabled = 0;\r
+ set_rotation_enabled(enabled);\r
break;\r
}\r
return 1;\r
/* Set defaults. */\r
SetDlgItemInt(tablist[NSSM_TAB_ROTATION], IDC_ROTATE_SECONDS, 0, 0);\r
SetDlgItemInt(tablist[NSSM_TAB_ROTATION], IDC_ROTATE_BYTES_LOW, 0, 0);\r
+ set_rotation_enabled(0);\r
\r
/* Environment tab. */\r
tab.pszText = message_string(NSSM_GUI_TAB_ENVIRONMENT);\r
{\r
GROUPBOX "Throttling", IDC_STATIC, 7, 7, 251, 25\r
LTEXT "Delay restart if application runs for less than", IDC_STATIC, 13, 18, 137, 8, SS_LEFT\r
- EDITTEXT IDC_THROTTLE, 152, 16, 29, 12, ES_AUTOHSCROLL | ES_NUMBER\r
+ EDITTEXT IDC_THROTTLE, 155, 16, 29, 12, ES_AUTOHSCROLL | ES_NUMBER\r
LTEXT "ms", IDC_STATIC, 186, 18, 10, 8, SS_LEFT\r
GROUPBOX "Restart", IDC_STATIC, 7, 33, 251, 42\r
LTEXT "Action to take when application exits other\nthan in response to a controlled service\nshutdown:", IDC_STATIC, 14, 42, 134, 24, SS_LEFT\r
GROUPBOX "File rotation", IDC_STATIC, 7, 7, 251, 68\r
AUTOCHECKBOX "Replace existing Output and/or Error files", IDC_TRUNCATE, 13, 18, 145, 8\r
AUTOCHECKBOX "Rotate files", IDC_ROTATE, 13, 32, 51, 8\r
- AUTOCHECKBOX "Restrict rotation to files older than", IDC_ROTATE_SECONDS_ENABLED, 13, 46, 121, 8\r
+ LTEXT "Restrict rotation to files older than", IDC_STATIC, 25, 46, 121, 8\r
EDITTEXT IDC_ROTATE_SECONDS, 140, 44, 29, 12, ES_AUTOHSCROLL | ES_NUMBER\r
LTEXT "s", IDC_STATIC, 171, 46, 8, 8, SS_LEFT\r
- AUTOCHECKBOX "Restrict rotation to files bigger than", IDC_ROTATE_BYTES_LOW_ENABLED, 13, 60, 125, 8\r
+ LTEXT "Restrict rotation to files bigger than", IDC_STATIC, 25, 60, 125, 8\r
EDITTEXT IDC_ROTATE_BYTES_LOW, 140, 58, 49, 12, ES_AUTOHSCROLL | ES_NUMBER\r
LTEXT "kB", IDC_STATIC, 191, 60, 8, 8, SS_LEFT\r
}\r
// Used by nssm.rc\r
//\r
#define IDC_STATIC (-1)\r
-#define IDI_NSSM 101\r
-#define IDD_INSTALL 102\r
-#define IDD_REMOVE 103\r
-#define IDD_APPLICATION 104\r
-#define IDD_DETAILS 105\r
-#define IDD_IO 106\r
-#define IDD_ROTATION 107\r
-#define IDD_APPEXIT 108\r
-#define IDD_SHUTDOWN 109\r
-#define IDD_ENVIRONMENT 110\r
+#define IDI_NSSM 101\r
+#define IDD_INSTALL 102\r
+#define IDD_REMOVE 103\r
+#define IDD_APPLICATION 104\r
+#define IDD_DETAILS 105\r
+#define IDD_IO 106\r
+#define IDD_ROTATION 107\r
+#define IDD_APPEXIT 108\r
+#define IDD_SHUTDOWN 109\r
+#define IDD_ENVIRONMENT 110\r
#define IDC_PATH 1000\r
#define IDC_TAB1 1001\r
#define IDC_CANCEL 1002\r
#define IDC_ENVIRONMENT_REPLACE 1026\r
#define IDC_TRUNCATE 1027\r
#define IDC_ROTATE 1028\r
-#define IDC_ROTATE_SECONDS_ENABLED 1029\r
-#define IDC_ROTATE_SECONDS 1030\r
-#define IDC_ROTATE_BYTES_LOW_ENABLED 1031\r
-#define IDC_ROTATE_BYTES_LOW 1032\r
-#define IDC_DISPLAYNAME 1033\r
-#define IDC_DESCRIPTION 1034\r
-#define IDC_STARTUP 1035\r
+#define IDC_ROTATE_SECONDS 1029\r
+#define IDC_ROTATE_BYTES_LOW 1030\r
+#define IDC_DISPLAYNAME 1031\r
+#define IDC_DESCRIPTION 1032\r
+#define IDC_STARTUP 1033\r
\r
// Next default values for new objects\r
// \r
#ifndef APSTUDIO_READONLY_SYMBOLS\r
#define _APS_NEXT_RESOURCE_VALUE 111\r
#define _APS_NEXT_COMMAND_VALUE 40001\r
-#define _APS_NEXT_CONTROL_VALUE 1036\r
+#define _APS_NEXT_CONTROL_VALUE 1034\r
#define _APS_NEXT_SYMED_VALUE 101\r
#endif\r
#endif\r