X-Git-Url: http://git.iain.cx/?a=blobdiff_plain;f=gui.cpp;h=7955b1a15861323bda8a71b6b5595817d55a3cc4;hb=f3d91adc48a7618fd9c94cbc45143f89b47b59e4;hp=3d51236ab26b143abe39a7d32173f41c0234a130;hpb=a4ac5c7f008020fff5b667f72a2b9b642d37e5cb;p=nssm.git diff --git a/gui.cpp b/gui.cpp index 3d51236..7955b1a 100644 --- a/gui.cpp +++ b/gui.cpp @@ -28,6 +28,7 @@ int nssm_gui(int resource, char *name) { /* Go! */ MSG message; while (GetMessage(&message, 0, 0, 0)) { + if (IsDialogMessage(dlg, &message)) continue; TranslateMessage(&message); DispatchMessage(&message); } @@ -154,8 +155,8 @@ int remove(HWND window) { void browse(HWND window) { if (! window) return; - unsigned long bufsize = 256; - unsigned long len = bufsize; + size_t bufsize = 256; + size_t len = bufsize; OPENFILENAME ofn; ZeroMemory(&ofn, sizeof(ofn)); ofn.lStructSize = sizeof(ofn); @@ -164,18 +165,18 @@ void browse(HWND window) { if (ofn.lpstrFilter) { ZeroMemory((void *) ofn.lpstrFilter, bufsize); char *localised = message_string(NSSM_GUI_BROWSE_FILTER_APPLICATIONS); - _snprintf((char *) ofn.lpstrFilter, bufsize, localised); + _snprintf_s((char *) ofn.lpstrFilter, bufsize, _TRUNCATE, localised); /* "Applications" + NULL + "*.exe" + NULL */ len = strlen(localised) + 1; LocalFree(localised); - _snprintf((char *) ofn.lpstrFilter + len, bufsize - len, "*.exe"); + _snprintf_s((char *) ofn.lpstrFilter + len, bufsize - len, _TRUNCATE, "*.exe"); /* "All files" + NULL + "*.*" + NULL */ len += 6; localised = message_string(NSSM_GUI_BROWSE_FILTER_ALL_FILES); - _snprintf((char *) ofn.lpstrFilter + len, bufsize - len, localised); + _snprintf_s((char *) ofn.lpstrFilter + len, bufsize - len, _TRUNCATE, localised); len += strlen(localised) + 1; LocalFree(localised); - _snprintf((char *) ofn.lpstrFilter + len, bufsize - len, "*.*"); + _snprintf_s((char *) ofn.lpstrFilter + len, bufsize - len, _TRUNCATE, "*.*"); /* Remainder of the buffer is already zeroed */ } ofn.lpstrFile = new char[MAX_PATH];