X-Git-Url: http://git.iain.cx/?a=blobdiff_plain;f=gui.cpp;h=dfa1a22b852447ecca377cfa8be64c07ec0f1bab;hb=c03d51cbbfe9f4f8a28dbabbfc068573a1842b74;hp=3f34943915915a9ad37ea7b4221c33e5c6fbd962;hpb=2994e17c24d8a3d32937a92733ba1ee0f26dc33d;p=nssm.git diff --git a/gui.cpp b/gui.cpp index 3f34943..dfa1a22 100644 --- a/gui.cpp +++ b/gui.cpp @@ -117,6 +117,10 @@ int nssm_gui(int resource, nssm_service_t *service) { } } + if (service->no_console) { + SendDlgItemMessage(tablist[NSSM_TAB_PROCESS], IDC_CONSOLE, BM_SETCHECK, BST_UNCHECKED, 0); + } + /* Shutdown tab. */ if (! (service->stop_method & NSSM_STOP_METHOD_CONSOLE)) { SendDlgItemMessage(tablist[NSSM_TAB_SHUTDOWN], IDC_METHOD_CONSOLE, BM_SETCHECK, BST_UNCHECKED, 0); @@ -161,7 +165,7 @@ int nssm_gui(int resource, nssm_service_t *service) { if (! service->rotate_bytes_high) SetDlgItemInt(tablist[NSSM_TAB_ROTATION], IDC_ROTATE_BYTES_LOW, service->rotate_bytes_low, 0); /* Check if advanced settings are in use. */ - if (service->stdout_disposition ^ service->stderr_disposition || service->stdout_disposition & ~CREATE_ALWAYS || service->stderr_disposition & ~CREATE_ALWAYS) popup_message(dlg, MB_OK | MB_ICONWARNING, NSSM_GUI_WARN_STDIO); + if (service->stdout_disposition != service->stderr_disposition || (service->stdout_disposition != NSSM_STDOUT_DISPOSITION && service->stdout_disposition != CREATE_ALWAYS) || (service->stderr_disposition != NSSM_STDERR_DISPOSITION && service->stderr_disposition != CREATE_ALWAYS)) popup_message(dlg, MB_OK | MB_ICONWARNING, NSSM_GUI_WARN_STDIO); if (service->rotate_bytes_high) popup_message(dlg, MB_OK | MB_ICONWARNING, NSSM_GUI_WARN_ROTATE_BYTES); /* Environment tab. */ @@ -478,6 +482,9 @@ int configure(HWND window, nssm_service_t *service, nssm_service_t *orig_service } } + if (SendDlgItemMessage(tablist[NSSM_TAB_PROCESS], IDC_CONSOLE, BM_GETCHECK, 0, 0) & BST_CHECKED) service->no_console = 0; + else service->no_console = 1; + /* Get stop method stuff. */ check_stop_method(service, NSSM_STOP_METHOD_CONSOLE, IDC_METHOD_CONSOLE); check_stop_method(service, NSSM_STOP_METHOD_WINDOW, IDC_METHOD_WINDOW); @@ -746,15 +753,17 @@ void browse(HWND window, TCHAR *current, unsigned long flags, ...) { va_end(arg); /* Remainder of the buffer is already zeroed */ } - ofn.lpstrFile = new TCHAR[PATH_LENGTH]; - if (flags & OFN_NOVALIDATE) { - /* Directory hack. */ - _sntprintf_s(ofn.lpstrFile, _countof(ofn.lpstrFile), _TRUNCATE, _T(":%s:"), message_string(NSSM_GUI_BROWSE_FILTER_DIRECTORIES)); - ofn.nMaxFile = DIR_LENGTH; - } - else { - _sntprintf_s(ofn.lpstrFile, _countof(ofn.lpstrFile), _TRUNCATE, _T("%s"), current); - ofn.nMaxFile = PATH_LENGTH; + ofn.lpstrFile = (TCHAR *) HeapAlloc(GetProcessHeap(), 0, PATH_LENGTH * sizeof(TCHAR)); + if (ofn.lpstrFile) { + if (flags & OFN_NOVALIDATE) { + /* Directory hack. */ + _sntprintf_s(ofn.lpstrFile, PATH_LENGTH, _TRUNCATE, _T(":%s:"), message_string(NSSM_GUI_BROWSE_FILTER_DIRECTORIES)); + ofn.nMaxFile = DIR_LENGTH; + } + else { + _sntprintf_s(ofn.lpstrFile, PATH_LENGTH, _TRUNCATE, _T("%s"), current); + ofn.nMaxFile = PATH_LENGTH; + } } ofn.lpstrTitle = message_string(NSSM_GUI_BROWSE_TITLE); ofn.Flags = OFN_EXPLORER | OFN_HIDEREADONLY | OFN_PATHMUSTEXIST | flags; @@ -765,8 +774,7 @@ void browse(HWND window, TCHAR *current, unsigned long flags, ...) { SendMessage(window, WM_SETTEXT, 0, (LPARAM) ofn.lpstrFile); } if (ofn.lpstrFilter) HeapFree(GetProcessHeap(), 0, (void *) ofn.lpstrFilter); - - delete[] ofn.lpstrFile; + if (ofn.lpstrFile) HeapFree(GetProcessHeap(), 0, ofn.lpstrFile); } INT_PTR CALLBACK tab_dlg(HWND tab, UINT message, WPARAM w, LPARAM l) { @@ -955,6 +963,8 @@ INT_PTR CALLBACK nssm_dlg(HWND window, UINT message, WPARAM w, LPARAM l) { SendMessage(combo, CB_INSERTSTRING, NSSM_IDLE_PRIORITY, (LPARAM) message_string(NSSM_GUI_IDLE_PRIORITY_CLASS)); SendMessage(combo, CB_SETCURSEL, NSSM_NORMAL_PRIORITY, 0); + SendDlgItemMessage(tablist[NSSM_TAB_PROCESS], IDC_CONSOLE, BM_SETCHECK, BST_CHECKED, 0); + list = GetDlgItem(tablist[NSSM_TAB_PROCESS], IDC_AFFINITY); n = num_cpus(); SendMessage(list, LB_SETCOLUMNWIDTH, 16, 0);