Skip to content

Commit 8754d6d

Browse files
author
Iain Patterson
committed
Be more Windowsy.
Now that the GUI is more functional, it should behave more like a real Windows application. That means having an icon and modal messageboxes.
1 parent 2e2d124 commit 8754d6d

File tree

4 files changed

+71
-52
lines changed

4 files changed

+71
-52
lines changed

event.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ void print_message(FILE *file, unsigned long id, ...) {
7272
}
7373

7474
/* Show a GUI dialogue */
75-
int popup_message(unsigned int type, unsigned long id, ...) {
75+
int popup_message(HWND owner, unsigned int type, unsigned long id, ...) {
7676
va_list arg;
7777

7878
TCHAR *format = message_string(id);
@@ -89,7 +89,20 @@ int popup_message(unsigned int type, unsigned long id, ...) {
8989
}
9090
va_end(arg);
9191

92-
int ret = MessageBox(0, blurb, NSSM, type);
92+
MSGBOXPARAMS params;
93+
ZeroMemory(&params, sizeof(params));
94+
params.cbSize = sizeof(params);
95+
params.hInstance = GetModuleHandle(0);
96+
params.hwndOwner = owner;
97+
params.lpszText = blurb;
98+
params.lpszCaption = NSSM;
99+
params.dwStyle = type;
100+
if (type == MB_OK) {
101+
params.dwStyle |= MB_USERICON;
102+
params.lpszIcon = MAKEINTRESOURCE(IDI_NSSM);
103+
}
104+
105+
int ret = MessageBoxIndirect(&params);
93106

94107
LocalFree(format);
95108

event.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ TCHAR *error_string(unsigned long);
55
TCHAR *message_string(unsigned long);
66
void log_event(unsigned short, unsigned long, ...);
77
void print_message(FILE *, unsigned long, ...);
8-
int popup_message(unsigned int, unsigned long, ...);
8+
int popup_message(HWND, unsigned int, unsigned long, ...);
99

1010
#endif

gui.cpp

Lines changed: 54 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,16 @@ int nssm_gui(int resource, nssm_service_t *service) {
2727
/* Create window */
2828
HWND dlg = dialog(MAKEINTRESOURCE(resource), 0, nssm_dlg, (LPARAM) service);
2929
if (! dlg) {
30-
popup_message(MB_OK, NSSM_GUI_CREATEDIALOG_FAILED, error_string(GetLastError()));
30+
popup_message(0, MB_OK, NSSM_GUI_CREATEDIALOG_FAILED, error_string(GetLastError()));
3131
return 1;
3232
}
3333

34+
/* Load the icon. */
35+
HANDLE icon = LoadImage(GetModuleHandle(0), MAKEINTRESOURCE(IDI_NSSM), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0);
36+
if (icon) SendMessage(dlg, WM_SETICON, ICON_SMALL, (LPARAM) icon);
37+
icon = LoadImage(GetModuleHandle(0), MAKEINTRESOURCE(IDI_NSSM), IMAGE_ICON, GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON), 0);
38+
if (icon) SendMessage(dlg, WM_SETICON, ICON_BIG, (LPARAM) icon);
39+
3440
/* Remember what the window is for. */
3541
SetWindowLongPtr(dlg, GWLP_USERDATA, (LONG_PTR) resource);
3642

@@ -129,8 +135,8 @@ int nssm_gui(int resource, nssm_service_t *service) {
129135
if (! service->rotate_bytes_high) SetDlgItemInt(tablist[NSSM_TAB_ROTATION], IDC_ROTATE_BYTES_LOW, service->rotate_bytes_low, 0);
130136

131137
/* Check if advanced settings are in use. */
132-
if (service->stdout_disposition ^ service->stderr_disposition || service->stdout_disposition & ~CREATE_ALWAYS || service->stderr_disposition & ~CREATE_ALWAYS) popup_message(MB_OK | MB_ICONWARNING, NSSM_GUI_WARN_STDIO);
133-
if (service->rotate_bytes_high) popup_message(MB_OK | MB_ICONWARNING, NSSM_GUI_WARN_ROTATE_BYTES);
138+
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);
139+
if (service->rotate_bytes_high) popup_message(dlg, MB_OK | MB_ICONWARNING, NSSM_GUI_WARN_ROTATE_BYTES);
134140

135141
/* Environment tab. */
136142
TCHAR *env;
@@ -149,14 +155,14 @@ int nssm_gui(int resource, nssm_service_t *service) {
149155
TCHAR *formatted;
150156
unsigned long newlen;
151157
if (format_environment(env, envlen, &formatted, &newlen)) {
152-
popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_EVENT_OUT_OF_MEMORY, _T("environment"), _T("nssm_dlg()"));
158+
popup_message(dlg, MB_OK | MB_ICONEXCLAMATION, NSSM_EVENT_OUT_OF_MEMORY, _T("environment"), _T("nssm_dlg()"));
153159
}
154160
else {
155161
SetDlgItemText(tablist[NSSM_TAB_ENVIRONMENT], IDC_ENVIRONMENT, formatted);
156162
HeapFree(GetProcessHeap(), 0, formatted);
157163
}
158164
}
159-
if (service->envlen && service->env_extralen) popup_message(MB_OK | MB_ICONWARNING, NSSM_GUI_WARN_ENVIRONMENT);
165+
if (service->envlen && service->env_extralen) popup_message(dlg, MB_OK | MB_ICONWARNING, NSSM_GUI_WARN_ENVIRONMENT);
160166
}
161167

162168
/* Go! */
@@ -222,10 +228,10 @@ static inline void set_rotation_enabled(unsigned char enabled) {
222228
EnableWindow(GetDlgItem(tablist[NSSM_TAB_ROTATION], IDC_ROTATE_BYTES_LOW), enabled);
223229
}
224230

225-
static inline void check_io(TCHAR *name, TCHAR *buffer, unsigned long len, unsigned long control) {
231+
static inline void check_io(HWND owner, TCHAR *name, TCHAR *buffer, unsigned long len, unsigned long control) {
226232
if (! SendMessage(GetDlgItem(tablist[NSSM_TAB_IO], control), WM_GETTEXTLENGTH, 0, 0)) return;
227233
if (GetDlgItemText(tablist[NSSM_TAB_IO], control, buffer, (int) len)) return;
228-
popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_MESSAGE_PATH_TOO_LONG, name);
234+
popup_message(owner, MB_OK | MB_ICONEXCLAMATION, NSSM_MESSAGE_PATH_TOO_LONG, name);
229235
ZeroMemory(buffer, len * sizeof(TCHAR));
230236
}
231237

@@ -242,15 +248,15 @@ int configure(HWND window, nssm_service_t *service, nssm_service_t *orig_service
242248

243249
/* Get service name. */
244250
if (! GetDlgItemText(window, IDC_NAME, service->name, _countof(service->name))) {
245-
popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_MISSING_SERVICE_NAME);
251+
popup_message(window, MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_MISSING_SERVICE_NAME);
246252
cleanup_nssm_service(service);
247253
return 2;
248254
}
249255

250256
/* Get executable name */
251257
if (! service->native) {
252258
if (! GetDlgItemText(tablist[NSSM_TAB_APPLICATION], IDC_PATH, service->exe, _countof(service->exe))) {
253-
popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_MISSING_PATH);
259+
popup_message(window, MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_MISSING_PATH);
254260
return 3;
255261
}
256262

@@ -263,7 +269,7 @@ int configure(HWND window, nssm_service_t *service, nssm_service_t *orig_service
263269
/* Get flags. */
264270
if (SendMessage(GetDlgItem(tablist[NSSM_TAB_APPLICATION], IDC_FLAGS), WM_GETTEXTLENGTH, 0, 0)) {
265271
if (! GetDlgItemText(tablist[NSSM_TAB_APPLICATION], IDC_FLAGS, service->flags, _countof(service->flags))) {
266-
popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_INVALID_OPTIONS);
272+
popup_message(window, MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_INVALID_OPTIONS);
267273
return 4;
268274
}
269275
}
@@ -272,14 +278,14 @@ int configure(HWND window, nssm_service_t *service, nssm_service_t *orig_service
272278
/* Get details. */
273279
if (SendMessage(GetDlgItem(tablist[NSSM_TAB_DETAILS], IDC_DISPLAYNAME), WM_GETTEXTLENGTH, 0, 0)) {
274280
if (! GetDlgItemText(tablist[NSSM_TAB_DETAILS], IDC_DISPLAYNAME, service->displayname, _countof(service->displayname))) {
275-
popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_INVALID_DISPLAYNAME);
281+
popup_message(window, MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_INVALID_DISPLAYNAME);
276282
return 5;
277283
}
278284
}
279285

280286
if (SendMessage(GetDlgItem(tablist[NSSM_TAB_DETAILS], IDC_DESCRIPTION), WM_GETTEXTLENGTH, 0, 0)) {
281287
if (! GetDlgItemText(tablist[NSSM_TAB_DETAILS], IDC_DESCRIPTION, service->description, _countof(service->description))) {
282-
popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_INVALID_DESCRIPTION);
288+
popup_message(window, MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_INVALID_DESCRIPTION);
283289
return 5;
284290
}
285291
}
@@ -307,21 +313,21 @@ int configure(HWND window, nssm_service_t *service, nssm_service_t *orig_service
307313
/* Username. */
308314
service->usernamelen = SendMessage(GetDlgItem(tablist[NSSM_TAB_LOGON], IDC_USERNAME), WM_GETTEXTLENGTH, 0, 0);
309315
if (! service->usernamelen) {
310-
popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_MISSING_USERNAME);
316+
popup_message(window, MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_MISSING_USERNAME);
311317
return 6;
312318
}
313319
service->usernamelen++;
314320

315321
service->username = (TCHAR *) HeapAlloc(GetProcessHeap(), 0, service->usernamelen * sizeof(TCHAR));
316322
if (! service->username) {
317-
popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_EVENT_OUT_OF_MEMORY, _T("account name"), _T("install()"));
323+
popup_message(window, MB_OK | MB_ICONEXCLAMATION, NSSM_EVENT_OUT_OF_MEMORY, _T("account name"), _T("install()"));
318324
return 6;
319325
}
320326
if (! GetDlgItemText(tablist[NSSM_TAB_LOGON], IDC_USERNAME, service->username, (int) service->usernamelen)) {
321327
HeapFree(GetProcessHeap(), 0, service->username);
322328
service->username = 0;
323329
service->usernamelen = 0;
324-
popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_INVALID_USERNAME);
330+
popup_message(window, MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_INVALID_USERNAME);
325331
return 6;
326332
}
327333

@@ -341,11 +347,11 @@ int configure(HWND window, nssm_service_t *service, nssm_service_t *orig_service
341347

342348
if (! orig_service || ! orig_service->username || ! str_equiv(service->username, orig_service->username) || service->passwordlen || passwordlen) {
343349
if (! service->passwordlen) {
344-
popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_MISSING_PASSWORD);
350+
popup_message(window, MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_MISSING_PASSWORD);
345351
return 6;
346352
}
347353
if (passwordlen != service->passwordlen) {
348-
popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_MISSING_PASSWORD);
354+
popup_message(window, MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_MISSING_PASSWORD);
349355
return 6;
350356
}
351357
service->passwordlen++;
@@ -356,7 +362,7 @@ int configure(HWND window, nssm_service_t *service, nssm_service_t *orig_service
356362
HeapFree(GetProcessHeap(), 0, service->username);
357363
service->username = 0;
358364
service->usernamelen = 0;
359-
popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_EVENT_OUT_OF_MEMORY, _T("password confirmation"), _T("install()"));
365+
popup_message(window, MB_OK | MB_ICONEXCLAMATION, NSSM_EVENT_OUT_OF_MEMORY, _T("password confirmation"), _T("install()"));
360366
return 6;
361367
}
362368

@@ -367,7 +373,7 @@ int configure(HWND window, nssm_service_t *service, nssm_service_t *orig_service
367373
HeapFree(GetProcessHeap(), 0, service->username);
368374
service->username = 0;
369375
service->usernamelen = 0;
370-
popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_EVENT_OUT_OF_MEMORY, _T("password"), _T("install()"));
376+
popup_message(window, MB_OK | MB_ICONEXCLAMATION, NSSM_EVENT_OUT_OF_MEMORY, _T("password"), _T("install()"));
371377
return 6;
372378
}
373379

@@ -381,7 +387,7 @@ int configure(HWND window, nssm_service_t *service, nssm_service_t *orig_service
381387
HeapFree(GetProcessHeap(), 0, service->username);
382388
service->username = 0;
383389
service->usernamelen = 0;
384-
popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_INVALID_PASSWORD);
390+
popup_message(window, MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_INVALID_PASSWORD);
385391
return 6;
386392
}
387393

@@ -396,13 +402,13 @@ int configure(HWND window, nssm_service_t *service, nssm_service_t *orig_service
396402
HeapFree(GetProcessHeap(), 0, service->username);
397403
service->username = 0;
398404
service->usernamelen = 0;
399-
popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_INVALID_PASSWORD);
405+
popup_message(window, MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_INVALID_PASSWORD);
400406
return 6;
401407
}
402408

403409
/* Compare. */
404410
if (_tcsncmp(password, service->password, service->passwordlen)) {
405-
popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_MISSING_PASSWORD);
411+
popup_message(window, MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_MISSING_PASSWORD);
406412
SecureZeroMemory(password, service->passwordlen);
407413
HeapFree(GetProcessHeap(), 0, password);
408414
SecureZeroMemory(service->password, service->passwordlen);
@@ -437,9 +443,9 @@ int configure(HWND window, nssm_service_t *service, nssm_service_t *orig_service
437443
if (service->default_exit_action == CB_ERR) service->default_exit_action = 0;
438444

439445
/* Get I/O stuff. */
440-
check_io(_T("stdin"), service->stdin_path, _countof(service->stdin_path), IDC_STDIN);
441-
check_io(_T("stdout"), service->stdout_path, _countof(service->stdout_path), IDC_STDOUT);
442-
check_io(_T("stderr"), service->stderr_path, _countof(service->stderr_path), IDC_STDERR);
446+
check_io(window, _T("stdin"), service->stdin_path, _countof(service->stdin_path), IDC_STDIN);
447+
check_io(window, _T("stdout"), service->stdout_path, _countof(service->stdout_path), IDC_STDOUT);
448+
check_io(window, _T("stderr"), service->stderr_path, _countof(service->stderr_path), IDC_STDERR);
443449

444450
/* Override stdout and/or stderr. */
445451
if (SendDlgItemMessage(tablist[NSSM_TAB_ROTATION], IDC_TRUNCATE, BM_GETCHECK, 0, 0) & BST_CHECKED) {
@@ -459,13 +465,13 @@ int configure(HWND window, nssm_service_t *service, nssm_service_t *orig_service
459465
if (envlen) {
460466
TCHAR *env = (TCHAR *) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (envlen + 2) * sizeof(TCHAR));
461467
if (! env) {
462-
popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_EVENT_OUT_OF_MEMORY, _T("environment"), _T("install()"));
468+
popup_message(window, MB_OK | MB_ICONEXCLAMATION, NSSM_EVENT_OUT_OF_MEMORY, _T("environment"), _T("install()"));
463469
cleanup_nssm_service(service);
464470
return 5;
465471
}
466472

467473
if (! GetDlgItemText(tablist[NSSM_TAB_ENVIRONMENT], IDC_ENVIRONMENT, env, envlen + 1)) {
468-
popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_INVALID_ENVIRONMENT);
474+
popup_message(window, MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_INVALID_ENVIRONMENT);
469475
HeapFree(GetProcessHeap(), 0, env);
470476
cleanup_nssm_service(service);
471477
return 5;
@@ -475,7 +481,7 @@ int configure(HWND window, nssm_service_t *service, nssm_service_t *orig_service
475481
unsigned long newlen;
476482
if (unformat_environment(env, envlen, &newenv, &newlen)) {
477483
HeapFree(GetProcessHeap(), 0, env);
478-
popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_EVENT_OUT_OF_MEMORY, _T("environment"), _T("install()"));
484+
popup_message(window, MB_OK | MB_ICONEXCLAMATION, NSSM_EVENT_OUT_OF_MEMORY, _T("environment"), _T("install()"));
479485
cleanup_nssm_service(service);
480486
return 5;
481487
}
@@ -486,7 +492,7 @@ int configure(HWND window, nssm_service_t *service, nssm_service_t *orig_service
486492

487493
/* Test the environment is valid. */
488494
if (test_environment(env)) {
489-
popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_INVALID_ENVIRONMENT);
495+
popup_message(window, MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_INVALID_ENVIRONMENT);
490496
HeapFree(GetProcessHeap(), 0, env);
491497
cleanup_nssm_service(service);
492498
return 5;
@@ -518,37 +524,37 @@ int install(HWND window) {
518524
/* See if it works. */
519525
switch (install_service(service)) {
520526
case 1:
521-
popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_EVENT_OUT_OF_MEMORY, _T("service"), _T("install()"));
527+
popup_message(window, MB_OK | MB_ICONEXCLAMATION, NSSM_EVENT_OUT_OF_MEMORY, _T("service"), _T("install()"));
522528
cleanup_nssm_service(service);
523529
return 1;
524530

525531
case 2:
526-
popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_MESSAGE_OPEN_SERVICE_MANAGER_FAILED);
532+
popup_message(window, MB_OK | MB_ICONEXCLAMATION, NSSM_MESSAGE_OPEN_SERVICE_MANAGER_FAILED);
527533
cleanup_nssm_service(service);
528534
return 2;
529535

530536
case 3:
531-
popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_MESSAGE_PATH_TOO_LONG, NSSM);
537+
popup_message(window, MB_OK | MB_ICONEXCLAMATION, NSSM_MESSAGE_PATH_TOO_LONG, NSSM);
532538
cleanup_nssm_service(service);
533539
return 3;
534540

535541
case 4:
536-
popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_OUT_OF_MEMORY_FOR_IMAGEPATH);
542+
popup_message(window, MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_OUT_OF_MEMORY_FOR_IMAGEPATH);
537543
cleanup_nssm_service(service);
538544
return 4;
539545

540546
case 5:
541-
popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_INSTALL_SERVICE_FAILED);
547+
popup_message(window, MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_INSTALL_SERVICE_FAILED);
542548
cleanup_nssm_service(service);
543549
return 5;
544550

545551
case 6:
546-
popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_CREATE_PARAMETERS_FAILED);
552+
popup_message(window, MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_CREATE_PARAMETERS_FAILED);
547553
cleanup_nssm_service(service);
548554
return 6;
549555
}
550556

551-
popup_message(MB_OK, NSSM_MESSAGE_SERVICE_INSTALLED, service->name);
557+
popup_message(window, MB_OK, NSSM_MESSAGE_SERVICE_INSTALLED, service->name);
552558
cleanup_nssm_service(service);
553559
return 0;
554560
}
@@ -562,41 +568,41 @@ int remove(HWND window) {
562568
if (service) {
563569
/* Get service name */
564570
if (! GetDlgItemText(window, IDC_NAME, service->name, _countof(service->name))) {
565-
popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_MISSING_SERVICE_NAME);
571+
popup_message(window, MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_MISSING_SERVICE_NAME);
566572
cleanup_nssm_service(service);
567573
return 2;
568574
}
569575

570576
/* Confirm */
571-
if (popup_message(MB_YESNO, NSSM_GUI_ASK_REMOVE_SERVICE, service->name) != IDYES) {
577+
if (popup_message(window, MB_YESNO, NSSM_GUI_ASK_REMOVE_SERVICE, service->name) != IDYES) {
572578
cleanup_nssm_service(service);
573579
return 0;
574580
}
575581
}
576582

577583
switch (remove_service(service)) {
578584
case 1:
579-
popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_EVENT_OUT_OF_MEMORY, _T("service"), _T("remove()"));
585+
popup_message(window, MB_OK | MB_ICONEXCLAMATION, NSSM_EVENT_OUT_OF_MEMORY, _T("service"), _T("remove()"));
580586
cleanup_nssm_service(service);
581587
return 1;
582588

583589
case 2:
584-
popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_MESSAGE_OPEN_SERVICE_MANAGER_FAILED);
590+
popup_message(window, MB_OK | MB_ICONEXCLAMATION, NSSM_MESSAGE_OPEN_SERVICE_MANAGER_FAILED);
585591
cleanup_nssm_service(service);
586592
return 2;
587593

588594
case 3:
589-
popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_SERVICE_NOT_INSTALLED);
595+
popup_message(window, MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_SERVICE_NOT_INSTALLED);
590596
return 3;
591597
cleanup_nssm_service(service);
592598

593599
case 4:
594-
popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_REMOVE_SERVICE_FAILED);
600+
popup_message(window, MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_REMOVE_SERVICE_FAILED);
595601
cleanup_nssm_service(service);
596602
return 4;
597603
}
598604

599-
popup_message(MB_OK, NSSM_MESSAGE_SERVICE_REMOVED, service->name);
605+
popup_message(window, MB_OK, NSSM_MESSAGE_SERVICE_REMOVED, service->name);
600606
cleanup_nssm_service(service);
601607
return 0;
602608
}
@@ -612,28 +618,28 @@ int edit(HWND window, nssm_service_t *orig_service) {
612618

613619
switch (edit_service(service, true)) {
614620
case 1:
615-
popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_EVENT_OUT_OF_MEMORY, _T("service"), _T("edit()"));
621+
popup_message(window, MB_OK | MB_ICONEXCLAMATION, NSSM_EVENT_OUT_OF_MEMORY, _T("service"), _T("edit()"));
616622
cleanup_nssm_service(service);
617623
return 1;
618624

619625
case 3:
620-
popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_MESSAGE_PATH_TOO_LONG, NSSM);
626+
popup_message(window, MB_OK | MB_ICONEXCLAMATION, NSSM_MESSAGE_PATH_TOO_LONG, NSSM);
621627
cleanup_nssm_service(service);
622628
return 3;
623629

624630
case 4:
625-
popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_OUT_OF_MEMORY_FOR_IMAGEPATH);
631+
popup_message(window, MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_OUT_OF_MEMORY_FOR_IMAGEPATH);
626632
cleanup_nssm_service(service);
627633
return 4;
628634

629635
case 5:
630636
case 6:
631-
popup_message(MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_EDIT_PARAMETERS_FAILED);
637+
popup_message(window, MB_OK | MB_ICONEXCLAMATION, NSSM_GUI_EDIT_PARAMETERS_FAILED);
632638
cleanup_nssm_service(service);
633639
return 6;
634640
}
635641

636-
popup_message(MB_OK, NSSM_MESSAGE_SERVICE_EDITED, service->name);
642+
popup_message(window, MB_OK, NSSM_MESSAGE_SERVICE_EDITED, service->name);
637643
cleanup_nssm_service(service);
638644
return 0;
639645
}

0 commit comments

Comments
 (0)